diff options
| -rw-r--r-- | hardinfo/util.c | 117 | ||||
| -rw-r--r-- | includes/callbacks.h | 1 | ||||
| -rw-r--r-- | includes/hardinfo.h | 1 | ||||
| -rw-r--r-- | includes/uidefs.h | 8 | ||||
| -rwxr-xr-x | shell/callbacks.c | 46 | ||||
| -rw-r--r-- | shell/menu.c | 13 | ||||
| -rwxr-xr-x | shell/shell.c | 9 | 
7 files changed, 11 insertions, 184 deletions
diff --git a/hardinfo/util.c b/hardinfo/util.c index cf6857f8..60e43ab1 100644 --- a/hardinfo/util.c +++ b/hardinfo/util.c @@ -170,26 +170,20 @@ void widget_set_cursor(GtkWidget * widget, GdkCursorType cursor_type)  {      GdkCursor *cursor;      GdkDisplay *display; -#if GTK_CHECK_VERSION(3, 0, 0)      GdkWindow *gdk_window; -#endif      display = gtk_widget_get_display(widget); - -#if GTK_CHECK_VERSION(3, 0, 0) +    cursor = gdk_cursor_new_for_display(display, cursor_type);      gdk_window = gtk_widget_get_window(widget); -    if ((cursor = gdk_cursor_new_for_display(display, cursor_type))) { +    if (cursor) {          gdk_window_set_cursor(gdk_window, cursor);          gdk_display_flush(display); +#if GTK_CHECK_VERSION(3, 0, 0)          g_object_unref(cursor); -    }  #else -    if ((cursor = gdk_cursor_new(cursor_type))) { -        gdk_window_set_cursor(GDK_WINDOW(widget->window), cursor); -        gdk_display_flush(display);          gdk_cursor_unref(cursor); -    }  #endif +    }      while (gtk_events_pending())          gtk_main_iteration(); @@ -992,109 +986,6 @@ gint tree_view_get_visible_height(GtkTreeView * tv)      return nrows * rect.height;  } -void tree_view_save_image(gchar * filename) -{ -#if GTK_CHECK_VERSION(3, 0, 0) -    /* TODO:GTK3 needs conversion for gtk3 */ -#else -    /* this is ridiculously complicated :/ why in the hell gtk+ makes this kind of -       thing so difficult?  */ - -    /* FIXME: this does not work if the window (or part of it) isn't visible. does -       anyone know how to fix this? :/ */ -    Shell *shell = shell_get_main_shell(); -    GtkWidget *widget = shell->info->view; - -    PangoLayout *layout; -    PangoContext *context; -    PangoRectangle rect; - -    GdkPixmap *pm; -    GdkPixbuf *pb; -    GdkGC *gc; -    GdkColor black = { 0, 0, 0, 0 }; -    GdkColor white = { 0, 65535, 65535, 65535 }; - -    gint w, h, visible_height; -    gchar *tmp; - -    gboolean tv_enabled; - -    /* present the window */ -    gtk_window_present(GTK_WINDOW(shell->window)); - -    /* if the treeview is disabled, we need to enable it so we get the -       correct colors when saving. we make it insensitive later on if it -       was this way before entering this function */ -    tv_enabled = GTK_WIDGET_IS_SENSITIVE(widget); -    gtk_widget_set_sensitive(widget, TRUE); - -    gtk_widget_queue_draw(widget); - -    /* unselect things in the information treeview */ -    gtk_range_set_value(GTK_RANGE -			(GTK_SCROLLED_WINDOW(shell->info->scroll)-> -			 vscrollbar), 0.0); -    gtk_tree_selection_unselect_all(gtk_tree_view_get_selection -				    (GTK_TREE_VIEW(widget))); -    while (gtk_events_pending()) -	gtk_main_iteration(); - -    /* initialize stuff */ -    gc = gdk_gc_new(widget->window); -    gdk_gc_set_background(gc, &black); -    gdk_gc_set_foreground(gc, &white); - -    context = gtk_widget_get_pango_context(widget); -    layout = pango_layout_new(context); - -    visible_height = tree_view_get_visible_height(GTK_TREE_VIEW(widget)); - -    /* draw the title */ -    tmp = g_strdup_printf("<b><big>%s</big></b>\n<small>%s</small>", -			  shell->selected->name, -			  shell->selected->notefunc(shell->selected-> -						    number)); -    pango_layout_set_markup(layout, tmp, -1); -    pango_layout_set_width(layout, widget->allocation.width * PANGO_SCALE); -    pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); -    pango_layout_get_pixel_extents(layout, NULL, &rect); - -    w = widget->allocation.width; -    h = visible_height + rect.height; - -    pm = gdk_pixmap_new(widget->window, w, rect.height, -1); -    gdk_draw_rectangle(GDK_DRAWABLE(pm), gc, TRUE, 0, 0, w, rect.height); -    gdk_draw_layout_with_colors(GDK_DRAWABLE(pm), gc, 0, 0, layout, -				&white, &black); - -    /* copy the pixmap from the treeview and from the title */ -    pb = gdk_pixbuf_get_from_drawable(NULL, -				      widget->window, -				      NULL, 0, 0, 0, 0, w, h); -    pb = gdk_pixbuf_get_from_drawable(pb, -				      pm, -				      NULL, -				      0, 0, -				      0, visible_height, w, rect.height); - -    /* save the pixbuf to a png file */ -    gdk_pixbuf_save(pb, filename, "png", NULL, -		    "compression", "9", -		    "tEXt::hardinfo::version", VERSION, -		    "tEXt::hardinfo::arch", ARCH, NULL); - -    /* unref */ -    g_object_unref(pb); -    g_object_unref(layout); -    g_object_unref(pm); -    g_object_unref(gc); -    g_free(tmp); - -    gtk_widget_set_sensitive(widget, tv_enabled); -#endif -} -  static gboolean __idle_free_do(gpointer ptr)  {      g_free(ptr); diff --git a/includes/callbacks.h b/includes/callbacks.h index d53e1861..392d5767 100644 --- a/includes/callbacks.h +++ b/includes/callbacks.h @@ -24,7 +24,6 @@  void cb_about();  void cb_about_module(GtkAction *action);  void cb_generate_report(); -void cb_save_graphic();  void cb_quit();  void cb_refresh();  void cb_copy_to_clipboard(); diff --git a/includes/hardinfo.h b/includes/hardinfo.h index b16a6e94..243f850f 100644 --- a/includes/hardinfo.h +++ b/includes/hardinfo.h @@ -91,7 +91,6 @@ gchar       *strreplace(gchar *string, gchar *replace, gchar *replacement);  /* Widget utility functions */  void widget_set_cursor(GtkWidget *widget, GdkCursorType cursor_type);  gint tree_view_get_visible_height(GtkTreeView *tv); -void tree_view_save_image(gchar *filename);  /* File Chooser utility functions */  void      file_chooser_open_expander(GtkWidget *chooser); diff --git a/includes/uidefs.h b/includes/uidefs.h index 3bb1c88f..70d2de17 100644 --- a/includes/uidefs.h +++ b/includes/uidefs.h @@ -1,5 +1,5 @@  #ifndef __UIDEFS_H__ -#define __UIDEFS_H__  +#define __UIDEFS_H__  #include "config.h" @@ -12,7 +12,7 @@  #ifdef HAS_LIBSOUP  #define SYNC_MANAGER_ITEMS "		<separator/>" \ -"		<menuitem name=\"SyncManager\" action=\"SyncManagerAction\" />"  +"		<menuitem name=\"SyncManager\" action=\"SyncManagerAction\" />"  #else		/* !HAS_LIBSOUP */  #define SYNC_MANAGER_ITEMS @@ -24,10 +24,6 @@ char *uidefs_str = "<ui>" \  "		<menuitem name=\"Report\" action=\"ReportAction\" />" \  "		<menuitem name=\"Copy\" action=\"CopyAction\" />" \  SYNC_MANAGER_ITEMS -/* - * Save Image is not ready for prime time. Yet. - * "<menuitem name=\"SaveGraph\" action=\"SaveGraphAction\" />" \ - */  "		<separator/>" \  "		<menuitem name=\"Quit\" action=\"QuitAction\" />" \  "	</menu>" \ diff --git a/shell/callbacks.c b/shell/callbacks.c index 705f6d8a..9a5461fa 100755 --- a/shell/callbacks.c +++ b/shell/callbacks.c @@ -37,52 +37,6 @@ void cb_sync_manager()      sync_manager_show(shell->window);  } -void cb_save_graphic() -{ -    Shell *shell = shell_get_main_shell(); -    GtkWidget *dialog; -    gchar *filename; - -    /* save the pixbuf to a png file */ -#if GTK_CHECK_VERSION(3, 0, 0) -    dialog = gtk_file_chooser_dialog_new(_("Save Image"), -					 NULL, -					 GTK_FILE_CHOOSER_ACTION_SAVE, -					 "_Cancel", -					 GTK_RESPONSE_CANCEL, -					 "_Save", -					 GTK_RESPONSE_ACCEPT, NULL); -#else -    dialog = gtk_file_chooser_dialog_new(_("Save Image"), -					 NULL, -					 GTK_FILE_CHOOSER_ACTION_SAVE, -					 GTK_STOCK_CANCEL, -					 GTK_RESPONSE_CANCEL, -					 GTK_STOCK_SAVE, -					 GTK_RESPONSE_ACCEPT, NULL); -#endif - -    filename = g_strconcat(shell->selected->name, ".png", NULL); -    gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename); -    g_free(filename); - -    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { -	filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); -	gtk_widget_destroy(dialog); - -	shell_status_update(_("Saving image...")); - -	tree_view_save_image(filename); - -	shell_status_update(_("Done.")); -	g_free(filename); - -	return; -    } - -    gtk_widget_destroy(dialog); -} -  void cb_open_web_page()  {      open_url("http://www.hardinfo.org"); diff --git a/shell/menu.c b/shell/menu.c index f5724d31..e966f485 100644 --- a/shell/menu.c +++ b/shell/menu.c @@ -53,17 +53,12 @@ static GtkActionEntry entries[] = {       N_("_Open..."), NULL,       NULL,       G_CALLBACK(cb_sync_manager)}, -      +      {"CopyAction", GTK_STOCK_COPY,       N_("_Copy to Clipboard"), "<control>C",       N_("Copy to clipboard"),       G_CALLBACK(cb_copy_to_clipboard)}, -    {"SaveGraphAction", GTK_STOCK_SAVE_AS, -     N_("_Save image as..."), "<control>S", -     NULL, -     G_CALLBACK(cb_save_graphic)}, -      {"RefreshAction", GTK_STOCK_REFRESH,       N_("_Refresh"), "F5",       NULL, @@ -130,15 +125,15 @@ void menu_init(Shell * shell)      /* Pack up our objects:       * menu_box -> window       * actions -> action_group -     * action_group -> menu_manager */   -    gtk_action_group_set_translation_domain( action_group, "hardinfo" );//gettext  +     * action_group -> menu_manager */ +    gtk_action_group_set_translation_domain( action_group, "hardinfo" );//gettext      gtk_action_group_add_actions(action_group, entries,  				 G_N_ELEMENTS(entries), NULL);      gtk_action_group_add_toggle_actions(action_group, toggle_entries,  					G_N_ELEMENTS(toggle_entries),  					NULL);      gtk_ui_manager_insert_action_group(menu_manager, action_group, 0); -     +      /* Read in the UI from our XML file */      error = NULL; diff --git a/shell/shell.c b/shell/shell.c index f5358911..3cc13128 100755 --- a/shell/shell.c +++ b/shell/shell.c @@ -284,9 +284,7 @@ void shell_view_set_enabled(gboolean setting)      shell_action_set_enabled("CopyAction", setting);      shell_action_set_enabled("ReportAction", setting);      shell_action_set_enabled("SyncManagerAction", setting && sync_manager_count_entries() > 0); -    shell_action_set_enabled("SaveGraphAction", -			     setting ? shell->view_type == -			     SHELL_VIEW_PROGRESS : FALSE); +  }  void shell_status_set_enabled(gboolean setting) @@ -764,7 +762,6 @@ void shell_init(GSList * modules)      shell_action_set_enabled("RefreshAction", FALSE);      shell_action_set_enabled("CopyAction", FALSE); -    shell_action_set_enabled("SaveGraphAction", FALSE);      shell_action_set_active("SidePaneAction", TRUE);      shell_action_set_active("ToolbarAction", TRUE); @@ -985,9 +982,6 @@ static void set_view_type(ShellViewType viewtype, gboolean reload)      /* turn off the rules hint */      gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(shell->info->view), FALSE); -    /* turn off the save graphic action */ -    shell_action_set_enabled("SaveGraphAction", FALSE); -      close_note(NULL, NULL);      switch (viewtype) { @@ -1043,7 +1037,6 @@ static void set_view_type(ShellViewType viewtype, gboolean reload)  	/* fallthrough */      case SHELL_VIEW_PROGRESS:          gtk_widget_show(shell->info->scroll); -	shell_action_set_enabled("SaveGraphAction", TRUE);  	if (!reload) {    	  gtk_tree_view_column_set_visible(shell->info->col_progress, TRUE);  | 
