forked from enlightenment/enlightenment
PackageKit: split config stuff to a proper e_mod_config.c file.
No functionan changes with this commit.
This commit is contained in:
parent
0d0907ec2a
commit
bf33f34b4c
|
@ -13,6 +13,8 @@ src_modules_packagekit_module_la_LDFLAGS = $(MOD_LDFLAGS)
|
||||||
src_modules_packagekit_module_la_SOURCES = \
|
src_modules_packagekit_module_la_SOURCES = \
|
||||||
src/modules/packagekit/e_mod_main.c \
|
src/modules/packagekit/e_mod_main.c \
|
||||||
src/modules/packagekit/e_mod_main.h \
|
src/modules/packagekit/e_mod_main.h \
|
||||||
|
src/modules/packagekit/e_mod_config.c \
|
||||||
|
src/modules/packagekit/e_mod_config.h \
|
||||||
src/modules/packagekit/e_mod_packagekit.c \
|
src/modules/packagekit/e_mod_packagekit.c \
|
||||||
src/modules/packagekit/e_mod_packagekit.h
|
src/modules/packagekit/e_mod_packagekit.h
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,124 @@
|
||||||
|
#include "e_mod_config.h"
|
||||||
|
#include "e_mod_packagekit.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct _E_Config_Dialog_Data
|
||||||
|
{
|
||||||
|
int update_interval;
|
||||||
|
char *manager_command;
|
||||||
|
int show_description;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void *
|
||||||
|
_cfg_data_create(E_Config_Dialog *cfd)
|
||||||
|
{
|
||||||
|
E_PackageKit_Module_Context *ctxt = cfd->data;
|
||||||
|
|
||||||
|
E_Config_Dialog_Data *cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||||
|
cfdata->update_interval = ctxt->config->update_interval;
|
||||||
|
cfdata->show_description = ctxt->config->show_description;
|
||||||
|
if (ctxt->config->manager_command)
|
||||||
|
cfdata->manager_command = strdup(ctxt->config->manager_command);
|
||||||
|
else
|
||||||
|
cfdata->manager_command = strdup("");
|
||||||
|
|
||||||
|
return cfdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cfg_data_free(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
|
||||||
|
{
|
||||||
|
E_FREE(cfdata->manager_command);
|
||||||
|
E_FREE(cfdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Evas_Object *
|
||||||
|
_cfg_widgets_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||||
|
{
|
||||||
|
Evas_Object *list, *of, *ob;
|
||||||
|
E_Radio_Group *rg;
|
||||||
|
|
||||||
|
list = e_widget_list_add(evas, 0, 0);
|
||||||
|
|
||||||
|
of = e_widget_framelist_add(evas, _("Refresh Packages"), 0);
|
||||||
|
rg = e_widget_radio_group_new(&(cfdata->update_interval));
|
||||||
|
ob = e_widget_radio_add(evas, _("Never"), 0, rg);
|
||||||
|
e_widget_framelist_object_append(of, ob);
|
||||||
|
ob = e_widget_radio_add(evas, _("Hourly"), 60, rg);
|
||||||
|
e_widget_framelist_object_append(of, ob);
|
||||||
|
ob = e_widget_radio_add(evas, _("Daily"), 60 * 24, rg);
|
||||||
|
e_widget_framelist_object_append(of, ob);
|
||||||
|
ob = e_widget_radio_add(evas, _("Weekly"), 60 * 24 * 7, rg);
|
||||||
|
e_widget_framelist_object_append(of, ob);
|
||||||
|
e_widget_list_object_append(list, of, 1, 1, 0.5);
|
||||||
|
|
||||||
|
of = e_widget_framelist_add(evas, _("Package list"), 0);
|
||||||
|
rg = e_widget_radio_group_new(&(cfdata->show_description));
|
||||||
|
ob = e_widget_radio_add(evas, _("Show package name"), 0, rg);
|
||||||
|
e_widget_framelist_object_append(of, ob);
|
||||||
|
ob = e_widget_radio_add(evas, _("Show package description"), 1, rg);
|
||||||
|
e_widget_framelist_object_append(of, ob);
|
||||||
|
e_widget_list_object_append(list, of, 1, 0, 0.5);
|
||||||
|
|
||||||
|
of = e_widget_framelist_add(evas, _("Package Manager"), 0);
|
||||||
|
ob = e_widget_entry_add(evas, &(cfdata->manager_command), NULL, NULL, NULL);
|
||||||
|
e_widget_framelist_object_append(of, ob);
|
||||||
|
e_widget_list_object_append(list, of, 1, 0, 0.5);
|
||||||
|
|
||||||
|
e_dialog_resizable_set(cfd->dia, 1);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_cfg_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||||
|
{
|
||||||
|
E_PackageKit_Module_Context *ctxt = cfd->data;
|
||||||
|
|
||||||
|
if (ctxt->config->update_interval != cfdata->update_interval)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (ctxt->config->show_description != cfdata->show_description)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if ((ctxt->config->manager_command) && (cfdata->manager_command) &&
|
||||||
|
(strcmp(ctxt->config->manager_command, cfdata->manager_command)))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if ((!ctxt->config->manager_command) && (cfdata->manager_command[0]))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_cfg_data_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||||
|
{
|
||||||
|
E_PackageKit_Module_Context *ctxt = cfd->data;
|
||||||
|
|
||||||
|
ctxt->config->update_interval = cfdata->update_interval;
|
||||||
|
ctxt->config->show_description = cfdata->show_description;
|
||||||
|
|
||||||
|
if (ctxt->config->manager_command)
|
||||||
|
eina_stringshare_replace(&ctxt->config->manager_command, cfdata->manager_command);
|
||||||
|
else
|
||||||
|
ctxt->config->manager_command = eina_stringshare_add(cfdata->manager_command);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
packagekit_config_show(E_PackageKit_Module_Context *ctxt)
|
||||||
|
{
|
||||||
|
E_Config_Dialog_View *v;
|
||||||
|
|
||||||
|
v = E_NEW(E_Config_Dialog_View, 1);
|
||||||
|
v->create_cfdata = _cfg_data_create;
|
||||||
|
v->free_cfdata = _cfg_data_free;
|
||||||
|
v->basic.create_widgets = _cfg_widgets_create;
|
||||||
|
v->basic.apply_cfdata = _cfg_data_apply;
|
||||||
|
v->basic.check_changed = _cfg_check_changed;
|
||||||
|
|
||||||
|
e_config_dialog_new(e_util_comp_current_get(), _("System Updates Settings"),
|
||||||
|
"E", "_e_mod_packagekit_dialog", NULL, 0, v, ctxt);
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef PACKAGEKIT_CONFIG_H
|
||||||
|
#define PACKAGEKIT_CONFIG_H
|
||||||
|
|
||||||
|
#include "e_mod_packagekit.h"
|
||||||
|
|
||||||
|
|
||||||
|
void packagekit_config_show(E_PackageKit_Module_Context *ctxt);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,7 @@
|
||||||
#include <e.h>
|
#include <e.h>
|
||||||
#include <Eldbus.h>
|
#include <Eldbus.h>
|
||||||
#include "e_mod_main.h"
|
#include "e_mod_main.h"
|
||||||
|
#include "e_mod_config.h"
|
||||||
#include "e_mod_packagekit.h"
|
#include "e_mod_packagekit.h"
|
||||||
|
|
||||||
#define PACKAGEKIT_DOMAIN "module.packagekit"
|
#define PACKAGEKIT_DOMAIN "module.packagekit"
|
||||||
|
@ -8,130 +9,14 @@
|
||||||
static E_Module *packagekit_mod = NULL;
|
static E_Module *packagekit_mod = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* Module Configuration */
|
|
||||||
struct _E_Config_Dialog_Data
|
|
||||||
{
|
|
||||||
int update_interval;
|
|
||||||
char *manager_command;
|
|
||||||
int show_description;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void *
|
|
||||||
_cfg_data_create(E_Config_Dialog *cfd)
|
|
||||||
{
|
|
||||||
E_PackageKit_Module_Context *ctxt = cfd->data;
|
|
||||||
|
|
||||||
E_Config_Dialog_Data *cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
|
||||||
cfdata->update_interval = ctxt->config->update_interval;
|
|
||||||
cfdata->show_description = ctxt->config->show_description;
|
|
||||||
if (ctxt->config->manager_command)
|
|
||||||
cfdata->manager_command = strdup(ctxt->config->manager_command);
|
|
||||||
else
|
|
||||||
cfdata->manager_command = strdup("");
|
|
||||||
|
|
||||||
return cfdata;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_cfg_data_free(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
|
|
||||||
{
|
|
||||||
E_FREE(cfdata->manager_command);
|
|
||||||
E_FREE(cfdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Evas_Object *
|
|
||||||
_cfg_widgets_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
|
||||||
{
|
|
||||||
Evas_Object *list, *of, *ob;
|
|
||||||
E_Radio_Group *rg;
|
|
||||||
|
|
||||||
list = e_widget_list_add(evas, 0, 0);
|
|
||||||
|
|
||||||
of = e_widget_framelist_add(evas, _("Refresh Packages"), 0);
|
|
||||||
rg = e_widget_radio_group_new(&(cfdata->update_interval));
|
|
||||||
ob = e_widget_radio_add(evas, _("Never"), 0, rg);
|
|
||||||
e_widget_framelist_object_append(of, ob);
|
|
||||||
ob = e_widget_radio_add(evas, _("Hourly"), 60, rg);
|
|
||||||
e_widget_framelist_object_append(of, ob);
|
|
||||||
ob = e_widget_radio_add(evas, _("Daily"), 60 * 24, rg);
|
|
||||||
e_widget_framelist_object_append(of, ob);
|
|
||||||
ob = e_widget_radio_add(evas, _("Weekly"), 60 * 24 * 7, rg);
|
|
||||||
e_widget_framelist_object_append(of, ob);
|
|
||||||
e_widget_list_object_append(list, of, 1, 1, 0.5);
|
|
||||||
|
|
||||||
of = e_widget_framelist_add(evas, _("Package list"), 0);
|
|
||||||
rg = e_widget_radio_group_new(&(cfdata->show_description));
|
|
||||||
ob = e_widget_radio_add(evas, _("Show package name"), 0, rg);
|
|
||||||
e_widget_framelist_object_append(of, ob);
|
|
||||||
ob = e_widget_radio_add(evas, _("Show package description"), 1, rg);
|
|
||||||
e_widget_framelist_object_append(of, ob);
|
|
||||||
e_widget_list_object_append(list, of, 1, 0, 0.5);
|
|
||||||
|
|
||||||
of = e_widget_framelist_add(evas, _("Package Manager"), 0);
|
|
||||||
ob = e_widget_entry_add(evas, &(cfdata->manager_command), NULL, NULL, NULL);
|
|
||||||
e_widget_framelist_object_append(of, ob);
|
|
||||||
e_widget_list_object_append(list, of, 1, 0, 0.5);
|
|
||||||
|
|
||||||
e_dialog_resizable_set(cfd->dia, 1);
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_cfg_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|
||||||
{
|
|
||||||
E_PackageKit_Module_Context *ctxt = cfd->data;
|
|
||||||
|
|
||||||
if (ctxt->config->update_interval != cfdata->update_interval)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (ctxt->config->show_description != cfdata->show_description)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if ((ctxt->config->manager_command) && (cfdata->manager_command) &&
|
|
||||||
(strcmp(ctxt->config->manager_command, cfdata->manager_command)))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if ((!ctxt->config->manager_command) && (cfdata->manager_command[0]))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_cfg_data_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|
||||||
{
|
|
||||||
E_PackageKit_Module_Context *ctxt = cfd->data;
|
|
||||||
|
|
||||||
ctxt->config->update_interval = cfdata->update_interval;
|
|
||||||
ctxt->config->show_description = cfdata->show_description;
|
|
||||||
|
|
||||||
if (ctxt->config->manager_command)
|
|
||||||
eina_stringshare_replace(&ctxt->config->manager_command, cfdata->manager_command);
|
|
||||||
else
|
|
||||||
ctxt->config->manager_command = eina_stringshare_add(cfdata->manager_command);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cfg_menu_cb(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
|
_cfg_menu_cb(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
|
||||||
{
|
{
|
||||||
E_Config_Dialog_View *v;
|
packagekit_config_show(data);
|
||||||
|
|
||||||
v = E_NEW(E_Config_Dialog_View, 1);
|
|
||||||
v->create_cfdata = _cfg_data_create;
|
|
||||||
v->free_cfdata = _cfg_data_free;
|
|
||||||
v->basic.create_widgets = _cfg_widgets_create;
|
|
||||||
v->basic.apply_cfdata = _cfg_data_apply;
|
|
||||||
v->basic.check_changed = _cfg_check_changed;
|
|
||||||
|
|
||||||
e_config_dialog_new(e_util_comp_current_get(), _("System Updates Settings"),
|
|
||||||
"E", "_e_mod_packagekit_dialog", NULL, 0, v, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
packagekit_mouse_down_cb(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
|
_mouse_down_cb(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
|
||||||
{
|
{
|
||||||
E_PackageKit_Instance *inst = data;
|
E_PackageKit_Instance *inst = data;
|
||||||
E_PackageKit_Module_Context *ctxt = packagekit_mod->data;
|
E_PackageKit_Module_Context *ctxt = packagekit_mod->data;
|
||||||
|
@ -174,6 +59,24 @@ packagekit_mouse_down_cb(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_refresh_timer_cb(void *data)
|
||||||
|
{
|
||||||
|
E_PackageKit_Module_Context *ctxt = data;
|
||||||
|
double elapsed;
|
||||||
|
|
||||||
|
if (ctxt->config->update_interval == 0)
|
||||||
|
return ECORE_CALLBACK_RENEW;
|
||||||
|
|
||||||
|
elapsed = (ecore_time_unix_get() - ctxt->config->last_update) / 60;
|
||||||
|
if (elapsed > ctxt->config->update_interval)
|
||||||
|
{
|
||||||
|
ctxt->config->last_update = ecore_time_unix_get();
|
||||||
|
packagekit_create_transaction_and_exec(ctxt, packagekit_refresh_cache);
|
||||||
|
}
|
||||||
|
return ECORE_CALLBACK_RENEW;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Gadcon Api Functions */
|
/* Gadcon Api Functions */
|
||||||
static E_Gadcon_Client *
|
static E_Gadcon_Client *
|
||||||
|
@ -190,7 +93,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
||||||
inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->gadget);
|
inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->gadget);
|
||||||
inst->gcc->data = inst;
|
inst->gcc->data = inst;
|
||||||
evas_object_event_callback_add(inst->gadget, EVAS_CALLBACK_MOUSE_DOWN,
|
evas_object_event_callback_add(inst->gadget, EVAS_CALLBACK_MOUSE_DOWN,
|
||||||
packagekit_mouse_down_cb, inst);
|
_mouse_down_cb, inst);
|
||||||
ctxt->instances = eina_list_append(ctxt->instances, inst);
|
ctxt->instances = eina_list_append(ctxt->instances, inst);
|
||||||
packagekit_icon_update(ctxt, EINA_FALSE);
|
packagekit_icon_update(ctxt, EINA_FALSE);
|
||||||
return inst->gcc;
|
return inst->gcc;
|
||||||
|
@ -258,24 +161,6 @@ static const E_Gadcon_Client_Class _gc_class =
|
||||||
/* E Module Api Functions */
|
/* E Module Api Functions */
|
||||||
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "PackageKit" };
|
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "PackageKit" };
|
||||||
|
|
||||||
Eina_Bool
|
|
||||||
_timer_cb(void *data)
|
|
||||||
{
|
|
||||||
E_PackageKit_Module_Context *ctxt = data;
|
|
||||||
double elapsed;
|
|
||||||
|
|
||||||
if (ctxt->config->update_interval == 0)
|
|
||||||
return ECORE_CALLBACK_RENEW;
|
|
||||||
|
|
||||||
elapsed = (ecore_time_unix_get() - ctxt->config->last_update) / 60;
|
|
||||||
if (elapsed > ctxt->config->update_interval)
|
|
||||||
{
|
|
||||||
ctxt->config->last_update = ecore_time_unix_get();
|
|
||||||
packagekit_create_transaction_and_exec(ctxt, packagekit_refresh_cache);
|
|
||||||
}
|
|
||||||
return ECORE_CALLBACK_RENEW;
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI void *
|
EAPI void *
|
||||||
e_modapi_init(E_Module *m)
|
e_modapi_init(E_Module *m)
|
||||||
{
|
{
|
||||||
|
@ -302,7 +187,7 @@ e_modapi_init(E_Module *m)
|
||||||
packagekit_mod = m;
|
packagekit_mod = m;
|
||||||
e_gadcon_provider_register(&_gc_class);
|
e_gadcon_provider_register(&_gc_class);
|
||||||
packagekit_dbus_connect(ctxt);
|
packagekit_dbus_connect(ctxt);
|
||||||
ctxt->refresh_timer = ecore_timer_add(60.0, _timer_cb, ctxt);
|
ctxt->refresh_timer = ecore_timer_add(60.0, _refresh_timer_cb, ctxt);
|
||||||
return ctxt;
|
return ctxt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define PACKAGEKIT_H
|
#define PACKAGEKIT_H
|
||||||
|
|
||||||
#include <Eldbus.h>
|
#include <Eldbus.h>
|
||||||
|
#include <e.h>
|
||||||
|
|
||||||
|
|
||||||
#define PKITV07 (ctxt->v_maj == 0) && (ctxt->v_min == 7)
|
#define PKITV07 (ctxt->v_maj == 0) && (ctxt->v_min == 7)
|
||||||
|
|
Loading…
Reference in New Issue