diff options
Diffstat (limited to 'hardinfo2')
| -rw-r--r-- | hardinfo2/hardinfo.h | 2 | ||||
| -rw-r--r-- | hardinfo2/menu.c | 2 | ||||
| -rw-r--r-- | hardinfo2/remote.c | 3 | ||||
| -rw-r--r-- | hardinfo2/shell.c | 18 | ||||
| -rw-r--r-- | hardinfo2/shell.h | 1 | ||||
| -rw-r--r-- | hardinfo2/syncmanager.c | 8 | ||||
| -rw-r--r-- | hardinfo2/syncmanager.h | 1 | ||||
| -rw-r--r-- | hardinfo2/uidefs.h | 2 | ||||
| -rw-r--r-- | hardinfo2/util.c | 54 | ||||
| -rw-r--r-- | hardinfo2/xmlrpc-server.c | 2 | 
10 files changed, 87 insertions, 6 deletions
| diff --git a/hardinfo2/hardinfo.h b/hardinfo2/hardinfo.h index 755d4af4..2314c043 100644 --- a/hardinfo2/hardinfo.h +++ b/hardinfo2/hardinfo.h @@ -100,6 +100,7 @@ void          open_url(gchar *url);  GSList	     *modules_get_list(void);  GSList	     *modules_load_selected(void);  GSList       *modules_load_all(void); +void	      module_unload_all(void);  ModuleAbout  *module_get_about(ShellModule *module);  gchar        *seconds_to_string(unsigned int seconds); @@ -117,6 +118,7 @@ const gchar  *module_entry_get_note(ShellModuleEntry *module_entry);  gchar        *module_entry_get_field(ShellModuleEntry * module_entry, gchar * field);  gchar        *module_entry_get_moreinfo(ShellModuleEntry * module_entry); +  /* BinReloc stuff */  gboolean binreloc_init(gboolean try_hardcoded); diff --git a/hardinfo2/menu.c b/hardinfo2/menu.c index 5a274978..b42225bd 100644 --- a/hardinfo2/menu.c +++ b/hardinfo2/menu.c @@ -53,7 +53,7 @@ static GtkActionEntry entries[] = {       G_CALLBACK(cb_sync_manager)},      {"ConnectToAction", GTK_STOCK_CONNECT, -     "_Connect to...", NULL, +     "_Connect to", NULL,       NULL,       G_CALLBACK(cb_connect_to)}, diff --git a/hardinfo2/remote.c b/hardinfo2/remote.c index 556299ca..5abf3a91 100644 --- a/hardinfo2/remote.c +++ b/hardinfo2/remote.c @@ -98,6 +98,9 @@ static gboolean load_module_list()          return FALSE;      } +    shell_status_update("Unloading local modules..."); +    module_unload_all(); +          for (; i < modules->n_values; i++) {          GValueArray *entries;          const gchar *module = g_value_get_string(&modules->values[i]); diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index c33be0ef..6a8ef1fd 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -249,6 +249,7 @@ void shell_view_set_enabled(gboolean setting)      gtk_widget_set_sensitive(shell->hpaned, setting);      shell_action_set_enabled("ViewMenuAction", setting); +    shell_action_set_enabled("ConnectToAction", setting);      shell_action_set_enabled("RefreshAction", setting);      shell_action_set_enabled("CopyAction", setting);      shell_action_set_enabled("ReportAction", setting); @@ -419,6 +420,7 @@ static void view_menu_select_entry(gpointer data, gpointer data2)  static void add_module_to_menu(gchar * name, GdkPixbuf * pixbuf)  {      gchar *about_module = g_strdup_printf("AboutModule%s", name); +    gint merge_id;      GtkActionEntry entries[] = {  	{ @@ -443,22 +445,27 @@ static void add_module_to_menu(gchar * name, GdkPixbuf * pixbuf)      gtk_action_group_add_actions(shell->action_group, entries, 2, NULL); +    merge_id = gtk_ui_manager_new_merge_id(shell->ui_manager);      gtk_ui_manager_add_ui(shell->ui_manager, -			  gtk_ui_manager_new_merge_id(shell->ui_manager), +                          merge_id,  			  "/menubar/ViewMenu/LastSep",  			  name, name, GTK_UI_MANAGER_MENU, TRUE); - +    shell->merge_ids = g_slist_prepend(shell->merge_ids, GINT_TO_POINTER(merge_id)); +         +    merge_id = gtk_ui_manager_new_merge_id(shell->ui_manager);      gtk_ui_manager_add_ui(shell->ui_manager, -			  gtk_ui_manager_new_merge_id(shell->ui_manager), +                          merge_id,  			  "/menubar/HelpMenu/HelpMenuModules/LastSep",  			  about_module, about_module, GTK_UI_MANAGER_AUTO,  			  TRUE); +    shell->merge_ids = g_slist_prepend(shell->merge_ids, GINT_TO_POINTER(merge_id));  }  static void  add_module_entry_to_view_menu(gchar * module, gchar * name,  			      GdkPixbuf * pixbuf, GtkTreeIter * iter)  { +    gint merge_id;      GtkActionEntry entries[] = {  	{  	 name,			/* name */ @@ -473,10 +480,12 @@ add_module_entry_to_view_menu(gchar * module, gchar * name,      stock_icon_register_pixbuf(pixbuf, name);      gtk_action_group_add_actions(shell->action_group, entries, 1, iter); +    merge_id = gtk_ui_manager_new_merge_id(shell->ui_manager);      gtk_ui_manager_add_ui(shell->ui_manager, -			  gtk_ui_manager_new_merge_id(shell->ui_manager), +                          merge_id,  			  g_strdup_printf("/menubar/ViewMenu/%s", module),  			  name, name, GTK_UI_MANAGER_AUTO, FALSE); +    shell->merge_ids = g_slist_prepend(shell->merge_ids, GINT_TO_POINTER(merge_id));  }  static void add_modules_to_gui(gpointer data, gpointer user_data) @@ -545,6 +554,7 @@ void shell_init(GSList * modules)      create_window(); +    shell_action_set_property("ConnectToAction", "is-important", TRUE);      shell_action_set_property("CopyAction", "is-important", TRUE);      shell_action_set_property("RefreshAction", "is-important", TRUE);      shell_action_set_property("ReportAction", "is-important", TRUE); diff --git a/hardinfo2/shell.h b/hardinfo2/shell.h index 6fe86009..c8e1e185 100644 --- a/hardinfo2/shell.h +++ b/hardinfo2/shell.h @@ -85,6 +85,7 @@ struct _Shell {      GtkActionGroup	*action_group;      GtkUIManager	*ui_manager; +    GSList		*merge_ids;      ShellViewType	 view_type;      gboolean		 normalize_percentage; diff --git a/hardinfo2/syncmanager.c b/hardinfo2/syncmanager.c index df2e1e7c..0aa560ca 100644 --- a/hardinfo2/syncmanager.c +++ b/hardinfo2/syncmanager.c @@ -113,6 +113,14 @@ void sync_manager_add_entry(SyncEntry * entry)  #endif				/* HAS_LIBSOUP */  } +void sync_manager_clear_entries(void) +{ +    DEBUG("clearing syncmanager entries"); +     +    g_slist_free(entries); +    entries = NULL; +} +  void sync_manager_show(GtkWidget *parent)  {  #ifndef HAS_LIBSOUP diff --git a/hardinfo2/syncmanager.h b/hardinfo2/syncmanager.h index d5385451..ae0ed267 100644 --- a/hardinfo2/syncmanager.h +++ b/hardinfo2/syncmanager.h @@ -35,6 +35,7 @@ struct _SyncEntry {  };  void sync_manager_add_entry(SyncEntry *entry); +void sync_manager_clear_entries(void);  void sync_manager_show(GtkWidget *parent);  gint sync_manager_count_entries(void); diff --git a/hardinfo2/uidefs.h b/hardinfo2/uidefs.h index ed1abf92..7da7a263 100644 --- a/hardinfo2/uidefs.h +++ b/hardinfo2/uidefs.h @@ -43,6 +43,8 @@ char *uidefs_str = "<ui>" \  "		<placeholder name=\"ToolItems\">" \  "			<toolitem name=\"Refresh\" action=\"RefreshAction\"/>" \  "			<separator/>" \ +"   		        <toolitem name=\"ConnectTo\" action=\"ConnectToAction\" />" \ +"			<separator/>" \  "			<toolitem name=\"Copy\" action=\"CopyAction\"/>" \  "			<toolitem name=\"Report\" action=\"ReportAction\"/>" \  "		</placeholder>" \ diff --git a/hardinfo2/util.c b/hardinfo2/util.c index 7b99f0ea..723077cf 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -45,6 +45,8 @@  #define MiB 1048576  #define GiB 1073741824 +static GSList *modules_list = NULL; +  gchar *find_program(gchar *program_name)  {      int i; @@ -577,6 +579,57 @@ gchar *module_call_method_param(gchar * method, gchar * parameter)      return function ? g_strdup(function(parameter)) : NULL;  } +static gboolean remove_module_methods(gpointer key, gpointer value, gpointer data) +{ +    return g_str_has_prefix(key, data); +} + +static void module_unload(ShellModule * module) +{ +    GSList *entry; +    gchar *name; +     +    name = g_path_get_basename(g_module_name(module->dll)); +    g_hash_table_foreach_remove(__module_methods, remove_module_methods, name); +     +    g_module_close(module->dll); +    g_free(module->name); +    gdk_pixbuf_unref(module->icon); +     +    for (entry = module->entries; entry; entry = entry->next) { +    	g_free(entry->data); +    } +     +    g_slist_free(module->entries); +    g_free(module); +    g_free(name); +} + +void module_unload_all(void) +{ +    Shell *shell; +    GSList *module, *merge_id; + +    shell = shell_get_main_shell(); +     +    for (module = shell->tree->modules; module; module = module->next) { +    	module_unload((ShellModule *)module->data); +    } +         +    for (merge_id = shell->merge_ids; merge_id; merge_id = merge_id->next) { +    	gtk_ui_manager_remove_ui(shell->ui_manager, +			         GPOINTER_TO_INT(merge_id->data)); +    } +     +    gtk_tree_store_clear(GTK_TREE_STORE(shell->tree->model)); +    sync_manager_clear_entries(); +     +    g_slist_free(shell->tree->modules); +    g_slist_free(shell->merge_ids); +    shell->merge_ids = NULL; +    shell->tree->modules = NULL; +} +  static ShellModule *module_load(gchar * filename)  {      ShellModule *module; @@ -808,7 +861,6 @@ static GSList *modules_check_deps(GSList * modules)      return modules;  } -static GSList *modules_list = NULL;  GSList *modules_get_list()  { diff --git a/hardinfo2/xmlrpc-server.c b/hardinfo2/xmlrpc-server.c index e0643e2a..a85e8a45 100644 --- a/hardinfo2/xmlrpc-server.c +++ b/hardinfo2/xmlrpc-server.c @@ -137,6 +137,8 @@ static void method_get_module_list(SoupMessage * msg, GValueArray * params)      for (modules = modules_get_list(); modules; modules = modules->next) {  	ShellModule *module = (ShellModule *) modules->data; +        /* gchar *name = g_path_get_basename(g_module_name(module->dll)); */ +  	soup_value_array_append(out, G_TYPE_STRING, module->name);      } | 
