Exemplo n.º 1
0
/*
 * Static methods
 */
static void
status_menu_populate (StatusMenu *self,
                      GSList *custom_status_array [NUM_STATUS_TYPES])
{
    gboolean has_custom_messages = false;
    GSList *custom_status = NULL;
    GSList *liter = NULL;
    GtkTreeIter iter;
    GdkPixbuf* icon = NULL;

    gtk_list_store_clear (GTK_LIST_STORE (self->priv->list_store));

    for (int i = 0 ; i < NUM_STATUS_TYPES ; i++) {

        statuses [i] = gettext (statuses [i]);
        custom_status = custom_status_array [i];
        liter = custom_status;

        icon = gtk_widget_render_icon (GTK_WIDGET (self),
                                       stock_status [i],
                                       GTK_ICON_SIZE_MENU, NULL);

        gtk_list_store_append (GTK_LIST_STORE (self->priv->list_store), &iter);
        gtk_list_store_set (GTK_LIST_STORE (self->priv->list_store), &iter,
                            COL_ICON, icon,
                            COL_MESSAGE, statuses[i],
                            COL_MESSAGE_TYPE, i,
                            COL_SEPARATOR, false,
                            -1);

        gtk_list_store_append (GTK_LIST_STORE (self->priv->list_store), &iter);
        gtk_list_store_set (GTK_LIST_STORE (self->priv->list_store), &iter,
                            COL_ICON, icon,
                            COL_MESSAGE, _("Custom message..."),
                            COL_MESSAGE_TYPE, NUM_STATUS_CUSTOM_TYPES + (i + 1),
                            COL_SEPARATOR, false,
                            -1);

        while (liter) {

            gtk_list_store_append (GTK_LIST_STORE (self->priv->list_store), &iter);
            gtk_list_store_set (GTK_LIST_STORE (self->priv->list_store), &iter,
                                COL_ICON, icon,
                                COL_MESSAGE, (char*) (liter->data),
                                COL_MESSAGE_TYPE, NUM_STATUS_TYPES + (i + 1),
                                COL_SEPARATOR, false,
                                -1);

            liter = g_slist_next (liter);
            has_custom_messages = true;
        }

        if (i < NUM_STATUS_TYPES - 1) {
            gtk_list_store_append (GTK_LIST_STORE (self->priv->list_store), &iter);
            gtk_list_store_set (GTK_LIST_STORE (self->priv->list_store), &iter,
                                COL_SEPARATOR, true,
                                -1);
        }

        g_object_unref (icon);
    }

    /* Clear message */
    if (has_custom_messages) {

        gtk_list_store_append (GTK_LIST_STORE (self->priv->list_store), &iter);
        gtk_list_store_set (GTK_LIST_STORE (self->priv->list_store), &iter,
                            COL_SEPARATOR, true,
                            -1);

        icon = gtk_widget_render_icon (GTK_WIDGET (self),
                                       GTK_STOCK_CLEAR,
                                       GTK_ICON_SIZE_MENU, NULL);
        gtk_list_store_append (GTK_LIST_STORE (self->priv->list_store), &iter);
        gtk_list_store_set (GTK_LIST_STORE (self->priv->list_store), &iter,
                            COL_ICON, icon,
                            COL_MESSAGE, _("Clear"),
                            COL_MESSAGE_TYPE, TYPE_CLEAR,
                            COL_SEPARATOR, false,
                            -1);
        g_object_unref (icon);
    }

    status_menu_set_option (self, self->priv->personal_details->get_presence (), self->priv->personal_details->get_status ());
}
static void
populate_store (GtkListStore *store,
		const gchar *path)
{
  GDir *dir;
  GError *error = NULL;
  gchar *item;
  GtkTreeIter iter;
  struct stat stat_info;
  GdkPixbuf *pixbuf = NULL;
  GtkWidget *dummy;

  dir = g_dir_open (path, 0, &error);
  if (error)
    {
      g_debug ("Error populating store: %s", error->message);
      g_error_free (error);
      return;
    }

  /* Dummy widget for gtk_widget_render_icon */
  dummy = gtk_label_new ("");

  while ((item = (gchar*)g_dir_read_name (dir)) != NULL)
    {
      gchar *file_path = g_strconcat (path, "/", item, NULL);

      if (stat (file_path, &stat_info) == -1)
	{
	  g_debug ("error retrieving stat info for %s", item);
	  continue;
	}
      g_free (file_path);

      gtk_list_store_append (store, &iter);

      if (S_ISDIR (stat_info.st_mode))
        {
          pixbuf = gtk_widget_render_icon (dummy, GTK_STOCK_DIRECTORY,
                                           GTK_ICON_SIZE_BUTTON, NULL);
        }
      else
        {
          pixbuf = gtk_widget_render_icon (dummy, GTK_STOCK_FILE,
                                           GTK_ICON_SIZE_BUTTON, NULL);
        }

      gtk_list_store_set (store, &iter,
			  ICON_COL, pixbuf,
			  STRING_COL, item,
			  IS_DIR_COL, S_ISDIR (stat_info.st_mode) ? TRUE : FALSE,
			  -1);
      if (pixbuf)
	g_object_unref (pixbuf);
    }

  g_dir_close (dir);

  gtk_widget_destroy (dummy);

  return;
}
Exemplo n.º 3
0
static GtkIconSet* accessx_status_applet_altgraph_icon_set(AccessxStatusApplet* sapplet, GtkWidget* widget)
{
    GtkIconSet* icon_set = gtk_icon_set_new();
    gint i;
    GtkStateType states[3] = {GTK_STATE_NORMAL, GTK_STATE_INSENSITIVE, GTK_STATE_SELECTED};
    GtkStyle* style = gtk_widget_get_style(widget);
    GdkPixbuf* icon_base;

    gtk_widget_set_sensitive(widget, TRUE);

    for (i = 0; i < 3; ++i)
    {
        int alpha;
        GdkColor* fg;
        GdkColor* bg;
        GtkIconSource* source = gtk_icon_source_new();
        GdkPixbuf* pixbuf;
        GdkPixbuf* glyph_pixbuf;
        gboolean wildcarded = FALSE;
        fg = &style->text[states[i]];
        bg = &style->white;
        switch (states[i])
        {
        case GTK_STATE_NORMAL:
            alpha = 255;
            gtk_widget_set_sensitive(widget, TRUE);
#if GTK_CHECK_VERSION (3, 0, 0)
            gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_NORMAL, TRUE);
#else
            gtk_widget_set_state(widget, GTK_STATE_NORMAL);
#endif
            break;
        case GTK_STATE_SELECTED:
            /* FIXME: should use text/base here, for selected ? */
            fg = &style->white;
            bg = &style->black;
            alpha = 255;
            gtk_widget_set_sensitive(widget, TRUE);
#if GTK_CHECK_VERSION (3, 0, 0)
            gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_SELECTED, TRUE);
#else
            gtk_widget_set_state(widget, GTK_STATE_SELECTED);
#endif
            break;
        case GTK_STATE_INSENSITIVE:
        default:
            alpha = 63;
            gtk_widget_set_sensitive(widget, FALSE);
            wildcarded = TRUE;
            break;
        }

        icon_base = gtk_widget_render_icon(widget, ACCESSX_BASE_ICON, icon_size_spec, NULL);
        pixbuf = gdk_pixbuf_copy(icon_base);
        g_object_unref(icon_base);
        /*
        * should be N_("ae"));
        * need en_ locale for this.
        */
        /*
        * Translators: substitute an easily-recognized single glyph
        * from Level 2, i.e. an AltGraph character from a common keyboard
        * in your locale.
        */
        glyph_pixbuf = accessx_status_applet_get_glyph_pixbuf(sapplet, widget, pixbuf, fg, bg, ("æ"));
        gdk_pixbuf_composite(glyph_pixbuf, pixbuf, 0, 0, gdk_pixbuf_get_width(glyph_pixbuf), gdk_pixbuf_get_height(glyph_pixbuf), 0., 0., 1.0, 1.0, GDK_INTERP_NEAREST, alpha);
        g_object_unref(glyph_pixbuf);
        gtk_icon_source_set_pixbuf(source, pixbuf);
        gtk_icon_source_set_state(source, states[i]);
        gtk_icon_source_set_state_wildcarded(source, wildcarded);
        gtk_icon_set_add_source(icon_set, source);
        gtk_icon_source_free(source);
    }
    /* we mucked about with the box's state to create the icons; restore it to normal */
#if GTK_CHECK_VERSION (3, 0, 0)
    gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_NORMAL, TRUE);
#else
    gtk_widget_set_state(widget, GTK_STATE_NORMAL);
#endif
    gtk_widget_set_sensitive(widget, TRUE);

    return icon_set;
}
Exemplo n.º 4
0
static void
xfburn_preferences_dialog_init (XfburnPreferencesDialog * obj)
{
  GtkBox *box = GTK_BOX (GTK_DIALOG (obj)->vbox);
  XfburnPreferencesDialogPrivate *priv = XFBURN_PREFERENCES_DIALOG_GET_PRIVATE (obj);
  
  GtkWidget *vbox, *vbox2, *vbox3, *hbox;
  GtkWidget *label;
  GtkWidget *frame;
  GtkWidget *scrolled_window;
  GtkListStore *icon_store, *store;
  gint x,y;
  GdkPixbuf *icon = NULL;
  GtkTreeIter iter;
  GtkTreeViewColumn *column_name;
  GtkCellRenderer *cell_icon, *cell_name;
  GtkWidget *button_close;
  gint idx;
  
  gtk_window_set_title (GTK_WINDOW (obj), _("Preferences"));
  xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (obj), _("Tune how Xfburn behaves"));
  gtk_window_set_default_size (GTK_WINDOW (obj), 775, 400);
  gtk_window_set_destroy_with_parent (GTK_WINDOW (obj), TRUE);
  gtk_window_set_icon_name (GTK_WINDOW (obj), GTK_STOCK_PREFERENCES);
  gtk_dialog_set_has_separator (GTK_DIALOG (obj), FALSE);
  
  hbox = gtk_hbox_new (FALSE, 0);
  gtk_box_pack_start (box, hbox, TRUE, TRUE, 0);
  gtk_widget_show (hbox);

  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  g_object_set (G_OBJECT (scrolled_window),
                "hscrollbar-policy", GTK_POLICY_NEVER,
                "shadow-type", GTK_SHADOW_IN,
                "vscrollbar-policy", GTK_POLICY_NEVER,
                NULL);
  gtk_box_pack_start (GTK_BOX (hbox), scrolled_window, FALSE, FALSE, 0);
  gtk_widget_show (scrolled_window);

  /* icon bar */
  icon_store = gtk_list_store_new (SETTINGS_LIST_N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
  priv->icon_bar = exo_icon_bar_new_with_model (GTK_TREE_MODEL (icon_store));
  exo_icon_bar_set_pixbuf_column (EXO_ICON_BAR (priv->icon_bar), SETTINGS_LIST_PIXBUF_COLUMN);
  exo_icon_bar_set_text_column (EXO_ICON_BAR (priv->icon_bar), SETTINGS_LIST_TEXT_COLUMN);
  gtk_container_add (GTK_CONTAINER (scrolled_window), priv->icon_bar);
  gtk_widget_show (priv->icon_bar);
  
  /* notebook */
  priv->notebook = gtk_notebook_new ();
  gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), BORDER);
  g_object_set (G_OBJECT (priv->notebook),
                "show-border", FALSE,
                "show-tabs", FALSE,
                NULL);
  gtk_box_pack_start (GTK_BOX (hbox), priv->notebook, TRUE, TRUE, BORDER);
  gtk_widget_show (priv->notebook);

  /* general tab */
  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER);
  idx = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), vbox, NULL);
  gtk_widget_show (vbox);

  vbox2 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox2);

  frame = xfce_gtk_frame_box_new_with_content (_("Temporary directory"), vbox2);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, BORDER);
  gtk_widget_show (frame);

  priv->chooser_button = gtk_file_chooser_button_new (_("Temporary directory"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
  gtk_box_pack_start (GTK_BOX (vbox2), priv->chooser_button, FALSE, FALSE, BORDER);
  gtk_widget_show (priv->chooser_button);

  priv->check_clean_tmpdir = gtk_check_button_new_with_mnemonic (_("_Clean temporary directory on exit"));
  gtk_box_pack_start (GTK_BOX (vbox2), priv->check_clean_tmpdir, FALSE, FALSE, BORDER);
  gtk_widget_show (priv->check_clean_tmpdir);

  vbox2 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox2);

  frame = xfce_gtk_frame_box_new_with_content (_("File browser"), vbox2);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, BORDER);
  gtk_widget_show (frame);

  priv->check_show_hidden = gtk_check_button_new_with_mnemonic (_("Show _hidden files"));
  gtk_box_pack_start (GTK_BOX (vbox2), priv->check_show_hidden, FALSE, FALSE, BORDER);
  gtk_widget_show (priv->check_show_hidden);
  g_signal_connect (G_OBJECT (priv->check_show_hidden), "clicked", G_CALLBACK (cb_show_hidden_clicked), NULL);

  priv->check_show_human_readable = gtk_check_button_new_with_mnemonic (_("Show human_readable filesizes"));
  gtk_box_pack_start (GTK_BOX (vbox2), priv->check_show_human_readable, FALSE, FALSE, BORDER);
  gtk_widget_show (priv->check_show_human_readable);

  icon = gtk_widget_render_icon (GTK_WIDGET (priv->icon_bar),
                                 GTK_STOCK_PROPERTIES,
                                 GTK_ICON_SIZE_DIALOG,
                                 NULL);
  gtk_list_store_append (icon_store, &iter);
  gtk_list_store_set (icon_store, &iter,
                      SETTINGS_LIST_PIXBUF_COLUMN, icon,
                      SETTINGS_LIST_TEXT_COLUMN, _("General"),
                      SETTINGS_LIST_INDEX_COLUMN, idx,
                      -1);
  g_object_unref (G_OBJECT (icon));
  
  /* devices tab */
  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), BORDER);
  idx = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), vbox, NULL);
  gtk_widget_show (vbox);

  label = gtk_label_new (_("Devices"));
  gtk_widget_show (label);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (priv->notebook),
                              gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), 1), label);
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);

  vbox2 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox2);

  frame = xfce_gtk_frame_box_new_with_content (_("Detected devices"), vbox2);
  gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, BORDER);
  gtk_widget_show (frame);

  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN);
  gtk_widget_show (scrolled_window);
  gtk_box_pack_start (GTK_BOX (vbox2), scrolled_window, TRUE, TRUE, BORDER);

  store = gtk_list_store_new (DEVICE_LIST_N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING,
                              G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
                              G_TYPE_BOOLEAN);
  priv->treeview_devices = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), DEVICE_LIST_COLUMN_NAME, GTK_SORT_ASCENDING);
  gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (priv->treeview_devices), TRUE);
  gtk_widget_show (priv->treeview_devices);
  gtk_container_add (GTK_CONTAINER (scrolled_window), priv->treeview_devices);
  g_object_unref (store);
  
  /* add columns */
  column_name = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column_name, _("Name"));
  gtk_tree_view_column_set_expand (column_name, TRUE);

  cell_icon = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (column_name, cell_icon, FALSE);
  gtk_tree_view_column_set_attributes (column_name, cell_icon, "pixbuf", DEVICE_LIST_COLUMN_ICON, NULL);
  g_object_set (cell_icon, "xalign", 0.0, "ypad", 0, NULL);

  cell_name = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column_name, cell_name, TRUE);
  gtk_tree_view_column_set_attributes (column_name, cell_name, "text", DEVICE_LIST_COLUMN_NAME, NULL);

  gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview_devices), column_name);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Node"),
                                               gtk_cell_renderer_text_new (), "text", DEVICE_LIST_COLUMN_NODE, NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write CD-R"),
                                               gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_CDR, NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write CD-RW"),
                                               gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_CDRW,
                                               NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write DVD-R"),
                                               gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_DVDR,
                                               NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write DVD-RAM"),
                                               gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_DVDRAM,
                                               NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->treeview_devices), -1, _("Write Blu-ray"),
                                               gtk_cell_renderer_toggle_new (), "active", DEVICE_LIST_COLUMN_BD,
                                               NULL);

  hbox = gtk_hbox_new (FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, BORDER);
  gtk_widget_show (hbox);

  priv->button_scan = xfce_gtk_button_new_mixed (GTK_STOCK_CDROM, _("Sc_an for devices"));
  gtk_box_pack_end (GTK_BOX (hbox), priv->button_scan, FALSE, FALSE, BORDER);
  g_signal_connect (G_OBJECT (priv->button_scan), "clicked", G_CALLBACK (scan_button_clicked_cb), obj);
  gtk_widget_show (priv->button_scan);

  gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &x, &y);
  icon = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), "media-optical", x, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL);
  if (!icon)
    icon = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), "media-cdrom", x, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL);
  if (!icon)
    icon = gtk_icon_theme_load_icon ( gtk_icon_theme_get_default(), GTK_STOCK_CDROM, x, GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL);

  
  gtk_list_store_append (icon_store, &iter);
  gtk_list_store_set (icon_store, &iter,
                      SETTINGS_LIST_PIXBUF_COLUMN, icon,
                      SETTINGS_LIST_TEXT_COLUMN, _("Devices"),
                      SETTINGS_LIST_INDEX_COLUMN, idx,
                      -1);
  if (icon)
    g_object_unref (G_OBJECT (icon));
  
  exo_mutual_binding_new (G_OBJECT (priv->notebook), "page", G_OBJECT (priv->icon_bar), "active");


  /* below the device list */
#if 0
  priv->check_empty_speed_list = gtk_check_button_new_with_mnemonic (_("Show warning on _empty speed list"));
  gtk_box_pack_start (GTK_BOX (vbox2), priv->check_empty_speed_list, FALSE, FALSE, BORDER);
  gtk_widget_show (priv->check_empty_speed_list);
#endif

  /* fifo */
  vbox3 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox3);

  frame = xfce_gtk_frame_box_new_with_content (_("FIFO buffer size (in kb)"), vbox3);
  gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, BORDER);
  gtk_widget_show (frame);

  priv->scale_fifo = gtk_hscale_new_with_range (0.0, FIFO_MAX_SIZE, 32.0);
  gtk_scale_set_value_pos (GTK_SCALE (priv->scale_fifo), GTK_POS_LEFT);
  gtk_range_set_value (GTK_RANGE (priv->scale_fifo), 0);
  gtk_box_pack_start (GTK_BOX (vbox3), priv->scale_fifo, FALSE, FALSE, BORDER/2);
  gtk_widget_show (priv->scale_fifo);

  
  /* action buttons */
  button_close = gtk_button_new_from_stock ("gtk-close");
  gtk_widget_show (button_close);
  gtk_dialog_add_action_widget (GTK_DIALOG (obj), button_close, GTK_RESPONSE_CLOSE);
  GTK_WIDGET_SET_FLAGS (button_close, GTK_CAN_DEFAULT);
  gtk_widget_grab_focus (button_close);
  gtk_widget_grab_default (button_close);

  g_signal_connect (G_OBJECT (obj), "response", G_CALLBACK (xfburn_preferences_dialog_response_cb), priv);
  
  refresh_devices_list (obj);
  
  g_object_unref (icon_store);
}
Exemplo n.º 5
0
static void serializer_append_icon_attribute (Serializer* self, GtkImage* image) {
    char* _tmp1_;
    char* _tmp0_ = NULL;
    gboolean _tmp2_;
    g_return_if_fail (self != NULL);
    g_return_if_fail (image != NULL);
    if ((_tmp2_ = (_tmp1_ = (g_object_get (image, "file", &_tmp0_, NULL), _tmp0_)) != NULL, _g_free0 (_tmp1_), _tmp2_)) {
        char* _tmp5_;
        char* _tmp4_;
        char* _tmp3_ = NULL;
        g_string_append (self->priv->sb, _tmp5_ = g_markup_printf_escaped (" icon=\"file:%s\"", _tmp4_ = (g_object_get (image, "file", &_tmp3_, NULL), _tmp3_)));
        _g_free0 (_tmp5_);
        _g_free0 (_tmp4_);
    } else {
        if (gtk_image_get_storage_type (image) == GTK_IMAGE_STOCK) {
            char* _tmp6_ = NULL;
            char* stock;
            stock = (g_object_get (image, "stock", &_tmp6_, NULL), _tmp6_);
            if (g_str_has_prefix (stock, "gtk")) {
                char* _tmp7_;
                g_string_append (self->priv->sb, _tmp7_ = g_markup_printf_escaped (" icon=\"%s\"", stock));
                _g_free0 (_tmp7_);
            } else {
                if (!self->disable_pixbuf) {
                    char* _tmp9_;
                    char* _tmp8_ = NULL;
                    GdkPixbuf* _tmp10_;
                    GdkPixbuf* pixbuf;
                    pixbuf = (_tmp10_ = gtk_widget_render_icon ((GtkWidget*) image, _tmp9_ = (g_object_get (image, "stock", &_tmp8_, NULL), _tmp8_), GTK_ICON_SIZE_MENU, NULL), _g_free0 (_tmp9_), _tmp10_);
                    if (pixbuf != NULL) {
                        char* _tmp12_;
                        char* _tmp11_;
                        g_string_append (self->priv->sb, _tmp12_ = g_markup_printf_escaped (" icon=\"pixbuf:%s\"", _tmp11_ = serializer_pixbuf_encode_b64 (self, pixbuf)));
                        _g_free0 (_tmp12_);
                        _g_free0 (_tmp11_);
                    }
                    _g_object_unref0 (pixbuf);
                }
            }
            _g_free0 (stock);
        }
        if (gtk_image_get_storage_type (image) == GTK_IMAGE_ICON_NAME) {
            char* _tmp15_;
            char* _tmp14_;
            char* _tmp13_ = NULL;
            g_string_append (self->priv->sb, _tmp15_ = g_markup_printf_escaped (" icon=\"theme:%s\"", _tmp14_ = (g_object_get (image, "icon-name", &_tmp13_, NULL), _tmp13_)));
            _g_free0 (_tmp15_);
            _g_free0 (_tmp14_);
        }
        if (gtk_image_get_storage_type (image) == GTK_IMAGE_PIXBUF) {
            if (!self->disable_pixbuf) {
                GdkPixbuf* _tmp17_;
                GdkPixbuf* _tmp16_ = NULL;
                gboolean _tmp18_;
                if ((_tmp18_ = (_tmp17_ = (g_object_get (image, "pixbuf", &_tmp16_, NULL), _tmp16_)) != NULL, _g_object_unref0 (_tmp17_), _tmp18_)) {
                    char* _tmp22_;
                    char* _tmp21_;
                    GdkPixbuf* _tmp20_;
                    GdkPixbuf* _tmp19_ = NULL;
                    g_string_append (self->priv->sb, _tmp22_ = g_markup_printf_escaped (" icon=\"pixbuf:%s\"", _tmp21_ = serializer_pixbuf_encode_b64 (self, _tmp20_ = (g_object_get (image, "pixbuf", &_tmp19_, NULL), _tmp19_))));
                    _g_free0 (_tmp22_);
                    _g_free0 (_tmp21_);
                    _g_object_unref0 (_tmp20_);
                }
            }
        }
        if (gtk_image_get_storage_type (image) == GTK_IMAGE_PIXMAP) {
            gulong pixmap_xid;
            gulong mask_xid;
            GdkPixmap* _tmp24_;
            GdkPixmap* _tmp23_ = NULL;
            gboolean _tmp25_;
            GdkPixmap* _tmp29_;
            GdkPixmap* _tmp28_ = NULL;
            gboolean _tmp30_;
            char* _tmp33_;
            pixmap_xid = (gulong) 0;
            mask_xid = (gulong) 0;
            if ((_tmp25_ = (_tmp24_ = (g_object_get (image, "pixmap", &_tmp23_, NULL), _tmp23_)) != NULL, _g_object_unref0 (_tmp24_), _tmp25_)) {
                GdkPixmap* _tmp27_;
                GdkPixmap* _tmp26_ = NULL;
                pixmap_xid = (gulong) gdk_x11_drawable_get_xid ((GdkDrawable*) (_tmp27_ = (g_object_get (image, "pixmap", &_tmp26_, NULL), _tmp26_)));
                _g_object_unref0 (_tmp27_);
            }
            if ((_tmp30_ = (_tmp29_ = (g_object_get (image, "mask", &_tmp28_, NULL), _tmp28_)) != NULL, _g_object_unref0 (_tmp29_), _tmp30_)) {
                GdkPixmap* _tmp32_;
                GdkPixmap* _tmp31_ = NULL;
                mask_xid = (gulong) gdk_x11_drawable_get_xid ((GdkDrawable*) (_tmp32_ = (g_object_get (image, "mask", &_tmp31_, NULL), _tmp31_)));
                _g_object_unref0 (_tmp32_);
            }
            g_string_append (self->priv->sb, _tmp33_ = g_markup_printf_escaped (" icon=\"pixmap:%lu,%lu\"", pixmap_xid, mask_xid));
            _g_free0 (_tmp33_);
        }
    }
}
Exemplo n.º 6
0
static void ygtk_help_dialog_init (YGtkHelpDialog *dialog)
{
	gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
	gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
	gtk_window_set_title (GTK_WINDOW (dialog), _("Help"));
	GdkPixbuf *icon = gtk_widget_render_icon (
		GTK_WIDGET (dialog), GTK_STOCK_HELP, GTK_ICON_SIZE_MENU, NULL);
	gtk_window_set_icon (GTK_WINDOW (dialog), icon);
	g_object_unref (G_OBJECT (icon));
	gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 450);

	// help text
	dialog->help_box = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy  (GTK_SCROLLED_WINDOW (dialog->help_box),
	                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (dialog->help_box),
	                                     GTK_SHADOW_IN);
	dialog->help_text = ygtk_html_wrap_new();
	gtk_container_add (GTK_CONTAINER (dialog->help_box), dialog->help_text);

#if 0  // show a nice background image
	GtkIconTheme *theme = gtk_icon_theme_get_default();
	GtkIconInfo *info = gtk_icon_theme_lookup_icon (theme, HELP_IMG_BG, 192, 0);
	if (info) {
		GdkPixbuf *pixbuf = gtk_icon_info_load_icon (info, NULL);
		if (pixbuf) {
			const gchar *filename = gtk_icon_info_get_filename (info);
			GdkPixbuf *transparent = ygutils_setOpacity (pixbuf, 60, FALSE);
			ygtk_html_wrap_set_background (dialog->help_text, transparent, filename);
			g_object_unref (pixbuf);
			g_object_unref (transparent);
		}
		gtk_icon_info_free (info);
	}
#endif

	// bottom part (search entry + close button)
	dialog->search_entry = gtk_entry_new();
	gtk_widget_set_size_request (dialog->search_entry, 140, -1);
	gtk_entry_set_icon_from_stock (GTK_ENTRY (dialog->search_entry),
		GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND);
	gtk_entry_set_icon_activatable (GTK_ENTRY (dialog->search_entry),
		GTK_ENTRY_ICON_PRIMARY, TRUE);
	g_signal_connect (G_OBJECT (dialog->search_entry), "icon-press",
	                  G_CALLBACK (search_entry_icon_press_cb), dialog);
	g_signal_connect (G_OBJECT (dialog->search_entry), "changed",
	                  G_CALLBACK (search_entry_changed_cb), dialog);
	g_signal_connect (G_OBJECT (dialog->search_entry), "activate",
	                  G_CALLBACK (search_entry_activated_cb), dialog);

	dialog->close_button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
        gtk_widget_set_can_default(dialog->close_button, TRUE);

	GtkWidget *close_box = gtk_hbutton_box_new();
	gtk_container_add (GTK_CONTAINER (close_box), dialog->close_button);

	char *label_str = ygutils_mapKBAccel (_("&Find:"));
	GtkWidget *bottom_box, *label = gtk_label_new_with_mnemonic (label_str);
	g_free (label_str);
	gtk_misc_set_alignment (GTK_MISC (label), 0, .5);
	gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->search_entry);

	bottom_box = gtk_hbox_new (FALSE, 2);
	gtk_box_pack_start (GTK_BOX (bottom_box), label, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (bottom_box), dialog->search_entry, FALSE, FALSE, 0);
	gtk_box_pack_end (GTK_BOX (bottom_box), close_box, FALSE, FALSE, 0);

#ifdef SET_HELP_HISTORY
	dialog->history_combo = gtk_combo_box_new_text();
	GList *cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (dialog->history_combo));
	g_object_set (G_OBJECT (cells->data), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
	g_list_free (cells);
#endif

	// glue it
	dialog->vbox = gtk_vbox_new (FALSE, 6);
#ifdef SET_HELP_HISTORY
	GtkWidget *hbox = gtk_hbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (hbox), gtk_image_new_from_stock (GTK_STOCK_HELP, GTK_ICON_SIZE_BUTTON), FALSE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), dialog->history_combo, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (dialog->vbox), hbox, FALSE, TRUE, 0);
#endif
	gtk_box_pack_start (GTK_BOX (dialog->vbox), dialog->help_box, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (dialog->vbox), bottom_box, FALSE, TRUE, 0);
	gtk_container_add (GTK_CONTAINER (dialog), dialog->vbox);
	gtk_widget_show_all (dialog->vbox);

	g_signal_connect (G_OBJECT (dialog->close_button), "clicked",
	                  G_CALLBACK (close_button_clicked_cb), dialog);
	g_signal_connect (G_OBJECT (dialog), "delete-event",
	                  G_CALLBACK (gtk_widget_hide_on_delete), NULL);
}
Exemplo n.º 7
0
void pidgin_log_show_contact(PurpleContact *contact) {
	struct log_viewer_hash_t *ht;
	PurpleBlistNode *child;
	PidginLogViewer *lv = NULL;
	GList *logs = NULL;
	GdkPixbuf *pixbuf;
	GtkWidget *image;
	const char *name = NULL;
	char *title;
	int total_log_size = 0;

	g_return_if_fail(contact != NULL);

	ht = g_new0(struct log_viewer_hash_t, 1);
	ht->type = PURPLE_LOG_IM;
	ht->contact = contact;

	if (log_viewers == NULL) {
		log_viewers = g_hash_table_new(log_viewer_hash, log_viewer_equal);
	} else if ((lv = g_hash_table_lookup(log_viewers, ht))) {
		gtk_window_present(GTK_WINDOW(lv->window));
		g_free(ht);
		return;
	}

	for (child = contact->node.child ; child ; child = child->next) {
		if (!PURPLE_BLIST_NODE_IS_BUDDY(child))
			continue;

		logs = g_list_concat(purple_log_get_logs(PURPLE_LOG_IM, ((PurpleBuddy *)child)->name,
						((PurpleBuddy *)child)->account), logs);
		total_log_size += purple_log_get_total_size(PURPLE_LOG_IM, ((PurpleBuddy *)child)->name, ((PurpleBuddy *)child)->account);
	}
	logs = g_list_sort(logs, purple_log_compare);

	image = gtk_image_new();
	pixbuf = gtk_widget_render_icon(image, PIDGIN_STOCK_STATUS_PERSON,
					gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_SMALL), "GtkWindow");
	if (pixbuf) {
		gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf);
		g_object_unref(pixbuf);
	} else {
		gtk_widget_destroy(image);
		image = NULL;
	}

	if (contact->alias != NULL)
		name = contact->alias;
	else if (contact->priority != NULL)
		name = purple_buddy_get_contact_alias(contact->priority);

	/* This will happen if the contact doesn't have an alias,
	 * and none of the contact's buddies are online.
	 * There is probably a better way to deal with this. */
	if (name == NULL) {
		if (contact->node.child != NULL && PURPLE_BLIST_NODE_IS_BUDDY(contact->node.child))
			name = purple_buddy_get_contact_alias((PurpleBuddy *) contact->node.child);
		if (name == NULL)
			name = "";
	}

	title = g_strdup_printf(_("Conversations with %s"), name);
	display_log_viewer(ht, logs, title, image, total_log_size);
	g_free(title);
}
Exemplo n.º 8
0
static void
pidgin_media_ready_cb(PurpleMedia *media, PidginMedia *gtkmedia, const gchar *sid)
{
	GtkWidget *send_widget = NULL, *recv_widget = NULL, *button_widget = NULL;
	PurpleMediaSessionType type =
			purple_media_get_session_type(media, sid);
	GdkPixbuf *icon = NULL;

	if (gtkmedia->priv->recv_widget == NULL
			&& type & (PURPLE_MEDIA_RECV_VIDEO |
			PURPLE_MEDIA_RECV_AUDIO)) {
		recv_widget = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);	
		gtk_box_pack_start(GTK_BOX(gtkmedia->priv->display),
				recv_widget, TRUE, TRUE, 0);
		gtk_widget_show(recv_widget);
	} else {
		recv_widget = gtkmedia->priv->recv_widget;
	}
	if (gtkmedia->priv->send_widget == NULL
			&& type & (PURPLE_MEDIA_SEND_VIDEO |
			PURPLE_MEDIA_SEND_AUDIO)) {
		send_widget = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
		gtk_box_pack_start(GTK_BOX(gtkmedia->priv->display),
				send_widget, FALSE, TRUE, 0);
		button_widget = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
		gtk_box_pack_end(GTK_BOX(recv_widget), button_widget,
				FALSE, TRUE, 0);
		gtk_widget_show(send_widget);

		/* Hold button */
		gtkmedia->priv->hold =
				gtk_toggle_button_new_with_mnemonic("_Hold");
		gtk_box_pack_end(GTK_BOX(button_widget), gtkmedia->priv->hold,
				FALSE, FALSE, 0);
		gtk_widget_show(gtkmedia->priv->hold);
		g_signal_connect(gtkmedia->priv->hold, "toggled",
				G_CALLBACK(pidgin_media_hold_toggled),
				gtkmedia);
	} else {
		send_widget = gtkmedia->priv->send_widget;
		button_widget = gtkmedia->priv->button_widget;
	}

	if (type & PURPLE_MEDIA_RECV_VIDEO) {
		PidginMediaRealizeData *data;
		GtkWidget *aspect;
		GtkWidget *remote_video;
		GdkColor color = {0, 0, 0, 0};

		aspect = gtk_aspect_frame_new(NULL, 0, 0, 4.0/3.0, FALSE);
		gtk_frame_set_shadow_type(GTK_FRAME(aspect), GTK_SHADOW_IN);
		gtk_box_pack_start(GTK_BOX(recv_widget), aspect, TRUE, TRUE, 0);

		data = g_new0(PidginMediaRealizeData, 1);
		data->gtkmedia = gtkmedia;
		data->session_id = g_strdup(sid);
		data->participant = g_strdup(gtkmedia->priv->screenname);

		remote_video = gtk_drawing_area_new();
		gtk_widget_modify_bg(remote_video, GTK_STATE_NORMAL, &color);
		g_signal_connect(G_OBJECT(remote_video), "realize",
				G_CALLBACK(realize_cb), data);
		gtk_container_add(GTK_CONTAINER(aspect), remote_video);
		gtk_widget_set_size_request (GTK_WIDGET(remote_video), 320, 240);
		gtk_widget_show(remote_video);
		gtk_widget_show(aspect);

		gtkmedia->priv->remote_video = remote_video;
	}

	if (type & PURPLE_MEDIA_SEND_VIDEO) {
		PidginMediaRealizeData *data;
		GtkWidget *aspect;
		GtkWidget *local_video;
		GdkColor color = {0, 0, 0, 0};

		aspect = gtk_aspect_frame_new(NULL, 0, 0, 4.0/3.0, TRUE);
		gtk_frame_set_shadow_type(GTK_FRAME(aspect), GTK_SHADOW_IN);
		gtk_box_pack_start(GTK_BOX(send_widget), aspect, FALSE, TRUE, 0);

		data = g_new0(PidginMediaRealizeData, 1);
		data->gtkmedia = gtkmedia;
		data->session_id = g_strdup(sid);
		data->participant = NULL;

		local_video = gtk_drawing_area_new();
		gtk_widget_modify_bg(local_video, GTK_STATE_NORMAL, &color);
		g_signal_connect(G_OBJECT(local_video), "realize",
				G_CALLBACK(realize_cb), data);
		gtk_container_add(GTK_CONTAINER(aspect), local_video);
		gtk_widget_set_size_request (GTK_WIDGET(local_video), 80, 60);

		gtk_widget_show(local_video);
		gtk_widget_show(aspect);

		gtkmedia->priv->pause =
				gtk_toggle_button_new_with_mnemonic(_("_Pause"));
		gtk_box_pack_end(GTK_BOX(button_widget), gtkmedia->priv->pause,
				FALSE, FALSE, 0);
		gtk_widget_show(gtkmedia->priv->pause);
		g_signal_connect(gtkmedia->priv->pause, "toggled",
				G_CALLBACK(pidgin_media_pause_toggled),
				gtkmedia);

		gtkmedia->priv->local_video = local_video;
	}
	if (type & PURPLE_MEDIA_RECV_AUDIO) {
		gtk_box_pack_end(GTK_BOX(recv_widget),
				pidgin_media_add_audio_widget(gtkmedia,
				PURPLE_MEDIA_RECV_AUDIO), FALSE, FALSE, 0);
	}

	if (type & PURPLE_MEDIA_SEND_AUDIO) {
		gtkmedia->priv->mute =
				gtk_toggle_button_new_with_mnemonic("_Mute");
		gtk_box_pack_end(GTK_BOX(button_widget), gtkmedia->priv->mute,
				FALSE, FALSE, 0);
		gtk_widget_show(gtkmedia->priv->mute);
		g_signal_connect(gtkmedia->priv->mute, "toggled",
				G_CALLBACK(pidgin_media_mute_toggled),
				gtkmedia);

		gtk_box_pack_end(GTK_BOX(recv_widget),
				pidgin_media_add_audio_widget(gtkmedia,
				PURPLE_MEDIA_SEND_AUDIO), FALSE, FALSE, 0);
	}

	if (type & PURPLE_MEDIA_AUDIO &&
			gtkmedia->priv->level_handler_id == 0) {
		gtkmedia->priv->level_handler_id = g_signal_connect(
				media, "level", G_CALLBACK(level_message_cb),
				gtkmedia);
	}

	if (send_widget != NULL)
		gtkmedia->priv->send_widget = send_widget;
	if (recv_widget != NULL)
		gtkmedia->priv->recv_widget = recv_widget;
	if (button_widget != NULL) {
		gtkmedia->priv->button_widget = button_widget;
		gtk_widget_show(GTK_WIDGET(button_widget));
	}

	if (purple_media_is_initiator(media, sid, NULL) == FALSE) {
		if (gtkmedia->priv->timeout_id != 0)
			g_source_remove(gtkmedia->priv->timeout_id);
		gtkmedia->priv->request_type |= type;
		gtkmedia->priv->timeout_id = g_timeout_add(500,
				(GSourceFunc)pidgin_request_timeout_cb,
				gtkmedia);
	}

	/* set the window icon according to the type */
	if (type & PURPLE_MEDIA_VIDEO) {
		icon = gtk_widget_render_icon(GTK_WIDGET(gtkmedia),
			PIDGIN_STOCK_TOOLBAR_VIDEO_CALL,
			gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_LARGE), NULL);
	} else if (type & PURPLE_MEDIA_AUDIO) {
		icon = gtk_widget_render_icon(GTK_WIDGET(gtkmedia),
			PIDGIN_STOCK_TOOLBAR_AUDIO_CALL,
			gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_LARGE), NULL);
	}

	if (icon) {
		gtk_window_set_icon(GTK_WINDOW(gtkmedia), icon);
		g_object_unref(icon);
	}
	
	gtk_widget_show(gtkmedia->priv->display);
}
Exemplo n.º 9
0
static void *
pidgin_notify_emails(PurpleConnection *gc, size_t count, gboolean detailed,
					   const char **subjects, const char **froms,
					   const char **tos, const char **urls)
{
	GtkWidget *dialog = NULL;
	char *notification;
	PurpleAccount *account;
	PidginNotifyMailData *data = NULL, *data2;
	gboolean new_data;

	/* Don't bother updating if there aren't new emails and we don't have any displayed currently */
	if (count == 0 && mail_dialog == NULL)
		return NULL;

	account = purple_connection_get_account(gc);
	dialog = pidgin_get_mail_dialog();  /* This creates mail_dialog if necessary */

	mail_dialog->total_count += count;
	if (detailed) {
		while (count--) {
			char *to_text = NULL;
			char *from_text = NULL;
			char *subject_text = NULL;
			char *tmp;
			gboolean first = TRUE;

			if (tos != NULL) {
				tmp = g_markup_escape_text(*tos, -1);
				to_text = g_strdup_printf("<b>%s</b>: %s\n", _("Account"), tmp);
				g_free(tmp);
				first = FALSE;
				tos++;
			}
			if (froms != NULL) {
				tmp = g_markup_escape_text(*froms, -1);
				from_text = g_strdup_printf("%s<b>%s</b>: %s\n", first ? "<br>" : "", _("Sender"), tmp);
				g_free(tmp);
				first = FALSE;
				froms++;
			}
			if (subjects != NULL) {
				tmp = g_markup_escape_text(*subjects, -1);
				subject_text = g_strdup_printf("%s<b>%s</b>: %s", first ? "<br>" : "", _("Subject"), tmp);
				g_free(tmp);
				first = FALSE;
				subjects++;
			}
#define SAFE(x) ((x) ? (x) : "")
			notification = g_strdup_printf("%s%s%s", SAFE(to_text), SAFE(from_text), SAFE(subject_text));
#undef SAFE
			g_free(to_text);
			g_free(from_text);
			g_free(subject_text);

			/* If we don't keep track of this, will leak "data" for each of the notifications except the last */
			data2 = pidgin_notify_add_mail(mail_dialog->treemodel, account, notification, urls ? *urls : NULL, 0, FALSE, &new_data);
			if (new_data) {
				if (data)
					data->purple_has_handle = FALSE;
				data = data2;
			}
			g_free(notification);

			if (urls != NULL)
				urls++;
		}
	} else {
		if (count > 0) {
			notification = g_strdup_printf(ngettext("%s has %d new message.",
							   "%s has %d new messages.",
							   (int)count),
							   *tos, (int)count);
			data2 = pidgin_notify_add_mail(mail_dialog->treemodel, account, notification, urls ? *urls : NULL, count, FALSE, &new_data);
			if (new_data) {
				if (data)
					data->purple_has_handle = FALSE;
				data = data2;
			}
			g_free(notification);
		} else {
			GtkTreeIter iter;

			/* Clear out all mails for the account */
			pidgin_notify_add_mail(mail_dialog->treemodel, account, NULL, NULL, 0, TRUE, NULL);

			if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(mail_dialog->treemodel), &iter)) {
				/* There is no API to clear the headline specifically */
				/* This will trigger reset_mail_dialog() */
				pidgin_blist_set_headline(NULL, NULL, NULL, NULL, NULL);
				return NULL;
			}
		}
	}

	if (!GTK_WIDGET_VISIBLE(dialog)) {
		GdkPixbuf *pixbuf = gtk_widget_render_icon(dialog, PIDGIN_STOCK_DIALOG_MAIL,
							   gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL), NULL);
		char *label_text = g_strdup_printf(ngettext("<b>%d new email.</b>",
							    "<b>%d new emails.</b>",
							    mail_dialog->total_count), mail_dialog->total_count);
		mail_dialog->in_use = TRUE;     /* So that _set_headline doesn't accidentally
										   remove the notifications when replacing an
										   old notification. */
		pidgin_blist_set_headline(label_text,
					    pixbuf, G_CALLBACK(gtk_widget_show_all), dialog,
					    (GDestroyNotify)reset_mail_dialog);
		mail_dialog->in_use = FALSE;
		g_free(label_text);
		if (pixbuf)
			g_object_unref(pixbuf);
	} else if (!GTK_WIDGET_HAS_FOCUS(dialog))
		pidgin_set_urgent(GTK_WINDOW(dialog), TRUE);

	return data;
}
Exemplo n.º 10
0
static void
xfburn_copy_dvd_dialog_init (XfburnCopyDvdDialog * obj)
{
  XfburnCopyDvdDialogPrivate *priv = XFBURN_COPY_DVD_DIALOG_GET_PRIVATE (obj);
  GtkBox *box = GTK_BOX (GTK_DIALOG (obj)->vbox);
  GtkWidget *img;
  GdkPixbuf *icon = NULL;
  GtkWidget *frame;
  GtkWidget *vbox;
  GtkWidget *align;
  GtkWidget *button;
  gchar *default_path, *tmp_dir;

  gtk_window_set_title (GTK_WINDOW (obj), _("Copy data DVD"));
  gtk_window_set_destroy_with_parent (GTK_WINDOW (obj), TRUE);
  icon = gtk_widget_render_icon (GTK_WIDGET (obj), XFBURN_STOCK_DATA_COPY, GTK_ICON_SIZE_DIALOG, NULL);
  gtk_window_set_icon (GTK_WINDOW (obj), icon);
  g_object_unref (icon);

  /* reader devices list */
  priv->device_box_src = xfburn_device_box_new (SHOW_DVD_READERS);
  gtk_widget_show (priv->device_box_src);
  
  frame = xfce_create_framebox_with_content (_("DVD Reader device"), priv->device_box_src);
  gtk_widget_show (frame);
  gtk_box_pack_start (box, frame, FALSE, FALSE, BORDER);

  /* burning devices list */
  priv->device_box_dest = xfburn_device_box_new (SHOW_DVD_WRITERS | SHOW_SPEED_SELECTION);
  gtk_widget_show (priv->device_box_dest);

  priv->frame_burn = xfce_create_framebox_with_content (_("Burning device"), priv->device_box_dest);
  gtk_widget_show (priv->frame_burn);
  gtk_box_pack_start (box, priv->frame_burn, FALSE, FALSE, BORDER);
    
  /* options */
  vbox = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox);

  frame = xfce_create_framebox_with_content (_("Options"), vbox);
  gtk_widget_show (frame);
  gtk_box_pack_start (box, frame, FALSE, FALSE, BORDER);

  priv->check_eject = gtk_check_button_new_with_mnemonic (_("E_ject disk"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->check_eject), TRUE);
  gtk_widget_show (priv->check_eject);
  gtk_box_pack_start (GTK_BOX (vbox), priv->check_eject, FALSE, FALSE, BORDER);

  priv->check_dummy = gtk_check_button_new_with_mnemonic (_("_Dummy write"));
  gtk_widget_show (priv->check_dummy);
  gtk_box_pack_start (GTK_BOX (vbox), priv->check_dummy, FALSE, FALSE, BORDER);

  priv->check_onthefly = gtk_check_button_new_with_mnemonic (_("On the _fly"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->check_onthefly), TRUE);
  gtk_widget_show (priv->check_onthefly);
  gtk_box_pack_start (GTK_BOX (vbox), priv->check_onthefly, FALSE, FALSE, BORDER);

  priv->check_only_iso = gtk_check_button_new_with_mnemonic (_("Only create _ISO"));
  gtk_widget_show (priv->check_only_iso);
  gtk_box_pack_start (GTK_BOX (vbox), priv->check_only_iso, FALSE, FALSE, BORDER);
  g_signal_connect (G_OBJECT (priv->check_only_iso), "toggled", G_CALLBACK (cb_check_only_iso_toggled), obj);

  align = gtk_alignment_new (0, 0, 0, 0);
  gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, BORDER * 4, 0);
  gtk_widget_show (align);
  gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
  priv->hbox_iso = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (priv->hbox_iso);
  gtk_container_add (GTK_CONTAINER (align), priv->hbox_iso);
  gtk_widget_set_sensitive (priv->hbox_iso, FALSE);

  priv->entry_path_iso = gtk_entry_new ();
  gtk_widget_show (priv->entry_path_iso);
  tmp_dir = xfburn_settings_get_string ("temporary-dir", "/tmp");
  default_path = g_build_filename (tmp_dir, "xfburn.iso", NULL);
  gtk_entry_set_text (GTK_ENTRY (priv->entry_path_iso), default_path);
  g_free (default_path);
  g_free (tmp_dir);
  gtk_box_pack_start (GTK_BOX (priv->hbox_iso), priv->entry_path_iso, FALSE, FALSE, 0);

  img = gtk_image_new_from_stock (GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_SMALL_TOOLBAR);
  gtk_widget_show (img);
  button = gtk_button_new ();
  gtk_container_add (GTK_CONTAINER (button), img);
  gtk_widget_show (button);
  gtk_box_pack_start (GTK_BOX (priv->hbox_iso), button, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (cb_browse_iso), obj);

  /* action buttons */
  button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
  gtk_widget_show (button);
  gtk_dialog_add_action_widget (GTK_DIALOG (obj), button, GTK_RESPONSE_CANCEL);

  button = xfce_create_mixed_button ("xfburn-data-copy", _("_Copy DVD"));
  gtk_widget_show (button);
  gtk_dialog_add_action_widget (GTK_DIALOG (obj), button, GTK_RESPONSE_OK);
  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
  gtk_widget_grab_focus (button);
  gtk_widget_grab_default (button);

  g_signal_connect (G_OBJECT (priv->device_box_src), "device-changed", G_CALLBACK (cb_device_changed), priv);
  g_signal_connect (G_OBJECT (priv->device_box_dest), "device-changed", G_CALLBACK (cb_device_changed), priv);
  
  /* check if the selected devices are the same */
  cb_device_changed (XFBURN_DEVICE_BOX (priv->device_box_dest), NULL, priv);
  
  g_signal_connect (G_OBJECT (obj), "response", G_CALLBACK (cb_dialog_response), priv);
}
Exemplo n.º 11
0
int
main (int argc, char **argv)
{
	GtkWidget *window, *hbox, *combo, *menu, *menuitem;
	GdkPixbuf *icon;

	gtk_init (&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	g_signal_connect (G_OBJECT (window), "delete_event", 
			  G_CALLBACK (gtk_main_quit), NULL);
	gtk_window_set_title (GTK_WINDOW (window), "Combo button test");
	gtk_window_set_resizable (GTK_WINDOW (window), FALSE);

	hbox = gtk_hbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (window), hbox);

	combo = gtk_button_new_from_stock (GTK_STOCK_OPEN);
	gtk_button_set_relief (GTK_BUTTON (combo), GTK_RELIEF_NONE);
	gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);	

	menu = gtk_menu_new ();
	menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_OPEN, NULL);
	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
	menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_SAVE, NULL);
	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
	gtk_widget_show_all (menu);
	
	combo = gdl_combo_button_new ();
	gdl_combo_button_set_label (GDL_COMBO_BUTTON (combo), "Run");
	gdl_combo_button_set_menu (GDL_COMBO_BUTTON (combo), GTK_MENU (menu));
	icon = gtk_widget_render_icon (combo, GTK_STOCK_EXECUTE,
				       GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
	gdl_combo_button_set_icon (GDL_COMBO_BUTTON (combo), icon);
	gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);

	g_signal_connect (combo, "activate_default",
			  G_CALLBACK (combo_button_activate_default_cb), NULL);

	combo = gtk_button_new_from_stock (GTK_STOCK_SAVE);
	gtk_button_set_relief (GTK_BUTTON (combo), GTK_RELIEF_NONE);
	gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);	

	menu = gtk_menu_new ();
	menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_OPEN, NULL);
	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
	menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_SAVE, NULL);
	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
	gtk_widget_show_all (menu);
	
	combo = gdl_combo_button_new ();
	gdl_combo_button_set_label (GDL_COMBO_BUTTON (combo), "Open");
	gdl_combo_button_set_menu (GDL_COMBO_BUTTON (combo), GTK_MENU (menu));
	icon = gtk_widget_render_icon (combo, GTK_STOCK_OPEN,
				       GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
	gdl_combo_button_set_icon (GDL_COMBO_BUTTON (combo), icon);
	gtk_widget_set_sensitive (combo, FALSE);
	gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);

	g_signal_connect (combo, "activate_default",
			  G_CALLBACK (combo_button_activate_default_cb), NULL);

	menu = gtk_menu_new ();
	combo = gdl_combo_button_new ();
	gdl_combo_button_set_label (GDL_COMBO_BUTTON (combo), "Open");
	gdl_combo_button_set_menu (GDL_COMBO_BUTTON (combo), GTK_MENU (menu));
	icon = gtk_widget_render_icon (combo, GTK_STOCK_OPEN,
				       GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
	gdl_combo_button_set_icon (GDL_COMBO_BUTTON (combo), icon);
	gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);

	gtk_widget_show_all (window);
	
	gtk_main ();

	return 0;
}
Exemplo n.º 12
0
static MapeFileIcon* mape_file_icon_new(GtkWidget* widget,
                                        MapeFileIconType type)
{
	MapeFileIcon* icon;
	GdkPixbuf* pixbuf;
	gint width, height;
	GdkPixbuf* scaled_pixbuf;
	GError *error = 0;

	switch(type)
	{
	case MAPE_FILE_ICON_DRIVE:
		pixbuf = gtk_widget_render_icon(
			widget,
			GTK_STOCK_HARDDISK,
			GTK_ICON_SIZE_BUTTON,
			NULL
		);
		break;
	case MAPE_FILE_ICON_FOLDER:
		pixbuf = gtk_widget_render_icon(
			widget,
			GTK_STOCK_DIRECTORY,
			GTK_ICON_SIZE_BUTTON,
			NULL
		);
		break;
	case MAPE_FILE_ICON_C4OBJECT:
		pixbuf = gdk_pixbuf_new_from_resource("/org/openclonk/mape/ocd.ico", &error);
		break;
	case MAPE_FILE_ICON_C4FOLDER:
		pixbuf = gdk_pixbuf_new_from_resource("/org/openclonk/mape/ocf.ico", &error);
		break;
	case MAPE_FILE_ICON_C4GROUP:
		pixbuf = gdk_pixbuf_new_from_resource("/org/openclonk/mape/ocg.ico", &error);
		break;
	case MAPE_FILE_ICON_C4SCENARIO:
		pixbuf = gdk_pixbuf_new_from_resource("/org/openclonk/mape/ocs.ico", &error);
		break;
	case MAPE_FILE_ICON_C4MATERIAL:
		pixbuf = gdk_pixbuf_new_from_resource("/org/openclonk/mape/ocm.ico", &error);
		break;
	default:
		g_assert_not_reached();
		break;
	}
	if (error)
	{
		fprintf (stderr, "Unable to create icon: %s\n", error->message);
		g_error_free (error);
	}

	if(pixbuf == NULL)
		return NULL;

	gtk_icon_size_lookup(GTK_ICON_SIZE_BUTTON, &width, &height);

	/* Scale pixbuf to size of GTK_ICON_SIZE_BUTTON */
	if(gdk_pixbuf_get_width(pixbuf) != width ||
	   gdk_pixbuf_get_height(pixbuf) != height)
	{
		scaled_pixbuf = gdk_pixbuf_scale_simple(
			pixbuf,
			width,
			height,
			GDK_INTERP_HYPER
		);

		g_object_unref(pixbuf);
		pixbuf = scaled_pixbuf;

		if(pixbuf == NULL)
			return NULL;
	}

	icon = malloc(sizeof(MapeFileIcon) );
	icon->type = type;
	icon->pixbuf = pixbuf;

	return icon;
}
Exemplo n.º 13
0
static MapeFileIcon* mape_file_icon_new(GtkWidget* widget,
                                        MapeFileIconType type)
{
	MapeFileIcon* icon;
	GdkPixbuf* pixbuf;
	gint width, height;
	GdkPixbuf* scaled_pixbuf;

	switch(type)
	{
	case MAPE_FILE_ICON_DRIVE:
		pixbuf = gtk_widget_render_icon(
			widget,
			GTK_STOCK_HARDDISK,
			GTK_ICON_SIZE_BUTTON,
			NULL
		);
		break;
	case MAPE_FILE_ICON_FOLDER:
		pixbuf = gtk_widget_render_icon(
			widget,
			GTK_STOCK_DIRECTORY,
			GTK_ICON_SIZE_BUTTON,
			NULL
		);
		break;
	case MAPE_FILE_ICON_C4OBJECT:
		pixbuf = gdk_pixbuf_new_from_inline(
			-1,
			mape_icon_ocd,
			FALSE,
			NULL
		);
		break;
	case MAPE_FILE_ICON_C4FOLDER:
		pixbuf = gdk_pixbuf_new_from_inline(
			-1,
			mape_icon_ocf,
			FALSE,
			NULL
		);
		break;
	case MAPE_FILE_ICON_C4GROUP:
		pixbuf = gdk_pixbuf_new_from_inline(
			-1,
			mape_icon_ocg,
			FALSE,
			NULL
		);
		break;
	case MAPE_FILE_ICON_C4SCENARIO:
		pixbuf = gdk_pixbuf_new_from_inline(
			-1,
			mape_icon_ocs,
			FALSE,
			NULL
		);
		break;
	case MAPE_FILE_ICON_C4MATERIAL:
		pixbuf = gdk_pixbuf_new_from_inline(
			-1,
			mape_icon_ocm,
			FALSE,
			NULL
		);
		break;
	default:
		g_assert_not_reached();
		break;
	}

	if(pixbuf == NULL)
		return NULL;

	gtk_icon_size_lookup(GTK_ICON_SIZE_BUTTON, &width, &height);

	/* Scale pixbuf to size of GTK_ICON_SIZE_BUTTON */
	if(gdk_pixbuf_get_width(pixbuf) != width ||
	   gdk_pixbuf_get_height(pixbuf) != height)
	{
		scaled_pixbuf = gdk_pixbuf_scale_simple(
			pixbuf,
			width,
			height,
			GDK_INTERP_HYPER
		);

		g_object_unref(pixbuf);
		pixbuf = scaled_pixbuf;

		if(pixbuf == NULL)
			return NULL;
	}

	icon = malloc(sizeof(MapeFileIcon) );
	icon->type = type;
	icon->pixbuf = pixbuf;

	return icon;
}
Exemplo n.º 14
0
static void
status_menu_new_status_message_dialog_run (StatusMenu *self,
        int option)
{
    gchar *presence = NULL;
    gchar *status = NULL;

    GSList *clist = NULL;
    GtkWidget *dialog = NULL;
    GtkWidget *label = NULL;
    GtkWidget *entry = NULL;
    GtkWidget *vbox = NULL;
    GtkWidget *hbox = NULL;
    GtkWidget *image = NULL;

    GdkPixbuf* icon = NULL;

    const char *message = NULL;

    presence = gm_conf_get_string (PERSONAL_DATA_KEY "short_status");
    status = gm_conf_get_string (PERSONAL_DATA_KEY "long_status");

    dialog = gtk_dialog_new_with_buttons (_("Custom Message"),
                                          self->priv->parent,
                                          (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
                                          GTK_STOCK_OK,
                                          GTK_RESPONSE_ACCEPT,
                                          NULL);
    gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);

    vbox = gtk_vbox_new (false, 0);
    gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
    gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox, false, false, 2);

    hbox = gtk_hbox_new (false, 2);
    icon = gtk_widget_render_icon (GTK_WIDGET (self),
                                   stock_status [option - NUM_STATUS_TYPES - 1],
                                   GTK_ICON_SIZE_MENU, NULL);
    gtk_window_set_icon (GTK_WINDOW (dialog), icon);
    image = gtk_image_new_from_pixbuf (icon);
    g_object_unref (icon);
    gtk_box_pack_start (GTK_BOX (hbox), image, false, false, 2);

    label = gtk_label_new (_("Define a custom message:"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_box_pack_start (GTK_BOX (hbox), label, false, false, 2);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, false, false, 2);

    entry = gtk_entry_new ();
    gtk_entry_set_activates_default (GTK_ENTRY (entry), true);
    gtk_box_pack_start (GTK_BOX (vbox), entry, false, false, 2);

    gtk_widget_show_all (dialog);
    switch (gtk_dialog_run (GTK_DIALOG (dialog))) {

    case GTK_RESPONSE_ACCEPT:
        message = gtk_entry_get_text (GTK_ENTRY (entry));
        clist = gm_conf_get_string_list (status_types_keys[option - NUM_STATUS_TYPES - 1]);
        if (message && strcmp (message, "")) {
            clist = g_slist_append (clist, g_strdup (message));
            gm_conf_set_string_list (status_types_keys[option - NUM_STATUS_TYPES - 1], clist);
            self->priv->personal_details->set_presence_info (status_types_names[option - NUM_STATUS_TYPES - 1], message);
        }
        else {
            status_menu_set_option (self, presence ? presence : "", status ? status : "");
        }
        g_slist_foreach (clist, (GFunc) g_free, NULL);
        g_slist_free (clist);
        break;

    default:
        status_menu_set_option (self, presence ? presence : "", status ? status : "");
        break;
    }

    gtk_widget_destroy (dialog);

    g_free (presence);
    g_free (status);
}
Exemplo n.º 15
0
void clist_refresh(void)
{
	GtkTreeView *view = GTK_TREE_VIEW(clist_wnd);
	GtkTreeSelection *selection;
	GtkTreeViewColumn *col;
	GtkTreeIter iter;
	GdkPixbuf *pix1, *pix2, *pix;
	GList *dirlist;
	gsize br, bw;
	gchar *utf8;
	int i;

	if(working_mode & MODE_CMD)
		return;

	// reparse folders
	tilp_local_selection_destroy();
	tilp_dirlist_local();

	selection = gtk_tree_view_get_selection(view);
	g_signal_handlers_block_by_func(G_OBJECT(selection), tree_selection_changed, NULL);
	gtk_list_store_clear(list);
	g_signal_handlers_unblock_by_func(G_OBJECT(selection), tree_selection_changed, NULL);

	// sort files
	for(i = 0; i < CLIST_NVCOLS; i++)
	{
		col = gtk_tree_view_get_column(view, i);
		gtk_tree_view_column_set_sort_indicator(col, FALSE);
	}

	switch (options.local_sort) 
	{
	case SORT_BY_NAME:
		tilp_file_sort_by_name();		
		col = gtk_tree_view_get_column(view, COLUMN_NAME);
		gtk_tree_view_column_set_sort_indicator(col, TRUE);
		gtk_tree_view_column_set_sort_order(col, options.local_sort_order ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
		break;
	case SORT_BY_TYPE:
		tilp_file_sort_by_type();
		col = gtk_tree_view_get_column(view, COLUMN_TYPE);
		gtk_tree_view_column_set_sort_indicator(col, TRUE);
		gtk_tree_view_column_set_sort_order(col, options.local_sort_order ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
		break;
	case SORT_BY_DATE:
		tilp_file_sort_by_date();
		col = gtk_tree_view_get_column(view, COLUMN_DATE);
		gtk_tree_view_column_set_sort_indicator(col, TRUE);
		gtk_tree_view_column_set_sort_order(col, options.local_sort_order ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
		break;
	case SORT_BY_SIZE:
		tilp_file_sort_by_size();
		col = gtk_tree_view_get_column(view, COLUMN_SIZE);
		gtk_tree_view_column_set_sort_indicator(col, TRUE);
		gtk_tree_view_column_set_sort_order(col, options.local_sort_order ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
		break;
	}

	pix2 = gtk_widget_render_icon(GTK_WIDGET(view), GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU, NULL);
	pix1 = gtk_widget_render_icon(GTK_WIDGET(view), GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU, NULL);

	for (dirlist = local.dirlist; dirlist != NULL; dirlist = dirlist->next) 
	{
		FileEntry *fe = (FileEntry *) dirlist->data;
		gboolean b;

		CalcModel s = tifiles_file_get_model(fe->name);
		CalcModel t = options.calc_model;

		b = options.show_all || S_ISDIR(fe->attrib) ||
			tifiles_file_is_tib(fe->name) ||
#if 0
			tifiles_file_is_tigroup(fe->name) ||
#else
			tifiles_file_test(fe->name, TIFILE_TIGROUP, options.calc_model) ||
#endif
			tifiles_calc_are_compat(s, t);
		if(!b)
			continue;

		if (S_ISDIR(fe->attrib)) 
		{
			pix = strcmp(fe->name, "..") ? pix2 : pix1; 
		} 
		else 
		{
			char icon_name[2048];

			strcpy(icon_name, tifiles_file_get_icon(fe->name));

			if (!strcmp(icon_name, ""))
				strcpy(icon_name, "TIicon1");

			strcat(icon_name, ".ico");
			tilp_file_underscorize(icon_name);
			pix = create_pixbuf(icon_name);
		}

		// filenames are stored in the 'glib filename encoding' and GTK+ uses utf8
		utf8 = g_filename_to_utf8(fe->name, -1, &br, &bw, NULL);
		gtk_list_store_append(list, &iter);
		gtk_list_store_set(list, &iter, 
				   COLUMN_NAME, utf8,
				   COLUMN_TYPE, tilp_file_get_type(fe),
				   COLUMN_SIZE, tilp_file_get_size(fe),
				   COLUMN_DATE, tilp_file_get_date(fe),
				   COLUMN_DATA, (gpointer) fe, 
                   COLUMN_ICON, pix, 
                   -1);
		g_free(utf8);
	}

	g_object_unref(pix1);
	g_object_unref(pix2);
}
Exemplo n.º 16
0
static void
update_detailed_info(GaimGtkXferDialog *dialog, GaimXfer *xfer)
{
	GaimGtkXferUiData *data;
	char *kbsec, *time_elapsed, *time_remaining;
	char *status, *utf8;

	if (dialog == NULL || xfer == NULL)
		return;

	data = GAIM_GTKXFER(xfer);

	get_xfer_info_strings(xfer, &kbsec, &time_elapsed, &time_remaining);

	status = g_strdup_printf("%ld of %ld",
							 (unsigned long)gaim_xfer_get_bytes_sent(xfer),
							 (unsigned long)gaim_xfer_get_size(xfer));

	if (gaim_xfer_get_size(xfer) >= 0 &&
		gaim_xfer_is_completed(xfer)) {

		GdkPixbuf *pixbuf = NULL;

		pixbuf = gtk_widget_render_icon(xfer_dialog->window,
										GAIM_STOCK_FILE_DONE,
										GTK_ICON_SIZE_MENU, NULL);

		gtk_list_store_set(GTK_LIST_STORE(xfer_dialog->model), &data->iter,
						   COLUMN_STATUS, pixbuf,
						   -1);

		g_object_unref(pixbuf);
	}

	if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) {
		gtk_label_set_markup(GTK_LABEL(dialog->local_user_desc_label),
							 _("<b>Receiving As:</b>"));
		gtk_label_set_markup(GTK_LABEL(dialog->remote_user_desc_label),
							 _("<b>Receiving From:</b>"));
	}
	else {
		gtk_label_set_markup(GTK_LABEL(dialog->remote_user_desc_label),
							 _("<b>Sending To:</b>"));
		gtk_label_set_markup(GTK_LABEL(dialog->local_user_desc_label),
							 _("<b>Sending As:</b>"));
	}

	gtk_label_set_text(GTK_LABEL(dialog->local_user_label), 
								 gaim_account_get_username(xfer->account));
	gtk_label_set_text(GTK_LABEL(dialog->remote_user_label), xfer->who);
	gtk_label_set_text(GTK_LABEL(dialog->protocol_label), 
								 gaim_account_get_protocol_name(xfer->account));

	if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) {
		gtk_label_set_text(GTK_LABEL(dialog->filename_label),
					   gaim_xfer_get_filename(xfer));
	} else {
		char *tmp;

		tmp = g_path_get_basename(gaim_xfer_get_local_filename(xfer));
		utf8 = g_filename_to_utf8(tmp, -1, NULL, NULL, NULL);
		g_free(tmp);

		gtk_label_set_text(GTK_LABEL(dialog->filename_label), utf8);
		g_free(utf8);
	}

	utf8 = g_filename_to_utf8((gaim_xfer_get_local_filename(xfer)), -1, NULL, NULL, NULL);
	gtk_label_set_text(GTK_LABEL(dialog->localfile_label), utf8);
	g_free(utf8);

	gtk_label_set_text(GTK_LABEL(dialog->status_label), status);

	gtk_label_set_text(GTK_LABEL(dialog->speed_label), kbsec);
	gtk_label_set_text(GTK_LABEL(dialog->time_elapsed_label), time_elapsed);
	gtk_label_set_text(GTK_LABEL(dialog->time_remaining_label),
					   time_remaining);

	gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(dialog->progress),
								  gaim_xfer_get_progress(xfer));

	g_free(kbsec);
	g_free(time_elapsed);
	g_free(time_remaining);
	g_free(status);
}
Exemplo n.º 17
0
void init_acct_features_dialog(struct acct_features_dialog *f_diag)
{
  GList *a = purple_accounts_get_all_active();
  /* TODO: should be freed ? */
  GdkPixbuf *yes = gtk_widget_render_icon(f_diag->window, GTK_STOCK_YES,
                                          GTK_ICON_SIZE_MENU, NULL);
  GdkPixbuf *no  = gtk_widget_render_icon(f_diag->window, GTK_STOCK_NO,
                                          GTK_ICON_SIZE_MENU, NULL);

  /* last line summarize all available features */
  GtkTreeIter e_iter;
  GdkPixbuf *e_icon     = gtk_widget_render_icon(f_diag->window,
                                                 PIDGIN_STOCK_INFO,
                                                 GTK_ICON_SIZE_MENU,
                                                 NULL);
  GdkPixbuf *e_pm        = no;
  GdkPixbuf *e_buddyicon = no;
  GdkPixbuf *e_nickname  = no;
  GdkPixbuf *e_mood      = no;
  GdkPixbuf *e_moodmsg   = no;
  GdkPixbuf *e_game      = no;
  GdkPixbuf *e_app       = no;
  GdkPixbuf *e_tune      = no;

  for(; a ; a = a->next) {
    PurpleAccount *acct  = (PurpleAccount *)a->data;
    PurplePlugin *plugin = purple_find_prpl(acct->protocol_id);
    PurplePluginProtocolInfo *protocol = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);

    GtkTreeIter iter;
    gchar *username = g_strdup_printf("%s (%s)",
                                           purple_account_get_username(acct),
                                           purple_account_get_protocol_name(acct));
    GdkPixbuf *a_icon = pidgin_create_prpl_icon(acct, PIDGIN_PRPL_ICON_MEDIUM);
    GHashTable *attrs  = get_account_attrs(acct);

    GdkPixbuf *nickname, *mood, *moodmsg, *game, *app, *tune, *pm, *buddyicon;

    if(g_hash_table_lookup(attrs, "mood"))
      e_mood = mood = yes;
    else
      mood = no;
    if(g_hash_table_lookup(attrs, "moodtext"))
      e_moodmsg = moodmsg = yes;
    else
      moodmsg = no;
    if(g_hash_table_lookup(attrs, "game"))
      e_game = game = yes;
    else
      game = no;
    if(g_hash_table_lookup(attrs, "office"))
      e_app = app = yes;
    else
      app = no;
    if((g_hash_table_lookup(attrs, "tune_title") &&
        g_hash_table_lookup(attrs, "tune_artist") &&
        g_hash_table_lookup(attrs, "tune_album")))
      e_tune = tune = yes;
    else
      tune = no;
    g_hash_table_destroy(attrs);

    if(protocol->set_status)
      e_pm = pm = yes;
    else
      pm = no;
    if(protocol->set_buddy_icon)
      e_buddyicon = buddyicon = yes;
    else
      buddyicon = no;
    /* exception for XMPP
       nickname supported
       manually
       FIXME: however some XMPP account don't support nickname extension */
    if(!strcmp(acct->protocol_id, "prpl-jabber") || protocol->set_public_alias)
      e_nickname = nickname = yes;
    else
      nickname = no;

    gtk_list_store_append(f_diag->list_store, &iter);
    gtk_list_store_set(f_diag->list_store, &iter,
                       ACCT_COLUMN, username,
                       ACCTICON_COLUMN, a_icon,
                       NICKNAME_COLUMN, nickname,
                       PM_COLUMN, pm,
                       ICON_COLUMN, buddyicon,
                       MOOD_COLUMN, mood,
                       MOODMSG_COLUMN, moodmsg,
                       TUNE_COLUMN, tune,
                       GAME_COLUMN, game,
                       APP_COLUMN, app,
                       -1);
    g_free(username);
  }

  /* last line summarize all available features */
  gtk_list_store_append(f_diag->list_store, &e_iter);
  gtk_list_store_set(f_diag->list_store, &e_iter,
                     ACCT_COLUMN, "Available features",
                     ACCTICON_COLUMN, e_icon,
                     NICKNAME_COLUMN, e_nickname,
                     PM_COLUMN, e_pm,
                     ICON_COLUMN, e_buddyicon,
                     MOOD_COLUMN, e_mood,
                     MOODMSG_COLUMN, e_moodmsg,
                     TUNE_COLUMN, e_tune,
                     GAME_COLUMN, e_game,
                     APP_COLUMN, e_app,
                     -1);
}
Exemplo n.º 18
0
void
gaim_gtkxfer_dialog_add_xfer(GaimGtkXferDialog *dialog, GaimXfer *xfer)
{
	GaimGtkXferUiData *data;
	GaimXferType type;
	GdkPixbuf *pixbuf;
	char *size_str, *remaining_str;
	char *lfilename, *utf8;

	g_return_if_fail(dialog != NULL);
	g_return_if_fail(xfer != NULL);

	gaim_xfer_ref(xfer);

	data = GAIM_GTKXFER(xfer);
	data->in_list = TRUE;

	gaim_gtkxfer_dialog_show(dialog);

	data->start_time = time(NULL);
	data->end_time = -1;

	type = gaim_xfer_get_type(xfer);

	size_str      = gaim_str_size_to_units(gaim_xfer_get_size(xfer));
	remaining_str = gaim_str_size_to_units(gaim_xfer_get_bytes_remaining(xfer));

	pixbuf = gtk_widget_render_icon(dialog->window,
									(type == GAIM_XFER_RECEIVE
									 ? GAIM_STOCK_DOWNLOAD
									 : GAIM_STOCK_UPLOAD),
									GTK_ICON_SIZE_MENU, NULL);

	gtk_list_store_append(dialog->model, &data->iter);
	lfilename = g_path_get_basename(gaim_xfer_get_local_filename(xfer));
	utf8 = g_filename_to_utf8(lfilename, -1, NULL, NULL, NULL);
	g_free(lfilename);
	lfilename = utf8;
	gtk_list_store_set(dialog->model, &data->iter,
					   COLUMN_STATUS, pixbuf,
					   COLUMN_PROGRESS, 0.0,
					   COLUMN_FILENAME, (type == GAIM_XFER_RECEIVE)
					                     ? gaim_xfer_get_filename(xfer)
							     : lfilename,
					   COLUMN_SIZE, size_str,
					   COLUMN_REMAINING, _("Waiting for transfer to begin"),
					   COLUMN_DATA, xfer,
					   -1);
	g_free(lfilename);

	gtk_tree_view_columns_autosize(GTK_TREE_VIEW(dialog->tree));

	g_object_unref(pixbuf);

	g_free(size_str);
	g_free(remaining_str);

	dialog->num_transfers++;

	ensure_row_selected(dialog);
}
Exemplo n.º 19
0
/* Shows the preferences dialog on the given tab */
void show_preferences(gint tab) {
  if(gtk_grab_get_current()) {
    /* A window is already open, so we present it to the user */
    GtkWidget *toplevel = gtk_widget_get_toplevel(gtk_grab_get_current());
    gtk_window_present((GtkWindow*)toplevel);
    return;
  }
  /* Declare some variables */
  GtkWidget *frame,     *label,
            *alignment, *hbox,
            *vbox;
  
  GtkObject *adjustment, *adjustment_small, *adjustment_statics;
  GtkTreeViewColumn *tree_column;
  
  /* Create the dialog */
  GtkWidget* dialog = gtk_dialog_new_with_buttons(_("Preferences"),     NULL,
                                                   (GTK_DIALOG_MODAL  + GTK_DIALOG_NO_SEPARATOR),
                                                    GTK_STOCK_CANCEL,   GTK_RESPONSE_REJECT,
                                                    GTK_STOCK_OK,       GTK_RESPONSE_ACCEPT, NULL);
  
  gtk_window_set_icon((GtkWindow*)dialog, gtk_widget_render_icon(dialog, GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU, NULL));
  gtk_window_set_resizable((GtkWindow*)dialog, FALSE);
  
  /* Create notebook */
  GtkWidget* notebook = gtk_notebook_new();
#if GTK_CHECK_VERSION (2,14,0)
  gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area (GTK_DIALOG(dialog))), notebook, TRUE, TRUE, 2);
#else
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook, TRUE, TRUE, 2);
#endif
  
  /* Build the settings page */  
  GtkWidget* page_settings = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)page_settings, 12, 6, 12, 6);
  gtk_notebook_append_page((GtkNotebook*)notebook, page_settings, gtk_label_new(_("Settings")));
  GtkWidget* vbox_settings = gtk_vbox_new(FALSE, 12);
  gtk_container_add((GtkContainer*)page_settings, vbox_settings);
  
  /* Build the clipboards frame */
  frame = gtk_frame_new(NULL);
  gtk_frame_set_shadow_type((GtkFrame*)frame, GTK_SHADOW_NONE);
  label = gtk_label_new(NULL);
  gtk_label_set_markup((GtkLabel*)label, _("<b>Clipboards</b>"));
  gtk_frame_set_label_widget((GtkFrame*)frame, label);
  alignment = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)alignment, 12, 0, 12, 0);
  gtk_container_add((GtkContainer*)frame, alignment);
  vbox = gtk_vbox_new(FALSE, 2);
  gtk_container_add((GtkContainer*)alignment, vbox);
  copy_check = gtk_check_button_new_with_mnemonic(_("Use _Copy (Ctrl-C)"));
  g_signal_connect((GObject*)copy_check, "toggled", (GCallback)check_toggled, NULL);
  gtk_box_pack_start((GtkBox*)vbox, copy_check, FALSE, FALSE, 0);
  primary_check = gtk_check_button_new_with_mnemonic(_("Use _Primary (Selection)"));
  g_signal_connect((GObject*)primary_check, "toggled", (GCallback)check_toggled, NULL);
  gtk_box_pack_start((GtkBox*)vbox, primary_check, FALSE, FALSE, 0);
  synchronize_check = gtk_check_button_new_with_mnemonic(_("S_ynchronize clipboards"));
  gtk_box_pack_start((GtkBox*)vbox, synchronize_check, FALSE, FALSE, 0);
  paste_check = gtk_check_button_new_with_mnemonic(_("_Automatically paste selected item"));
  g_signal_connect((GObject*)paste_check, "toggled", (GCallback)check_toggled, NULL);
  gtk_box_pack_start((GtkBox*)vbox, paste_check, FALSE, FALSE, 0);
  gtk_box_pack_start((GtkBox*)vbox_settings, frame, FALSE, FALSE, 0);

  /* Build the miscellaneous frame */
  frame = gtk_frame_new(NULL);
  gtk_frame_set_shadow_type((GtkFrame*)frame, GTK_SHADOW_NONE);
  label = gtk_label_new(NULL);
  gtk_label_set_markup((GtkLabel*)label, _("<b>Miscellaneous</b>"));
  gtk_frame_set_label_widget((GtkFrame*)frame, label);
  alignment = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)alignment, 12, 0, 12, 0);
  gtk_container_add((GtkContainer*)frame, alignment);
  vbox = gtk_vbox_new(FALSE, 2);
  gtk_container_add((GtkContainer*)alignment, vbox);
  show_indexes_check = gtk_check_button_new_with_mnemonic(_("Show _indexes in history menu"));
  gtk_box_pack_start((GtkBox*)vbox, show_indexes_check, FALSE, FALSE, 0);
  save_uris_check = gtk_check_button_new_with_mnemonic(_("S_ave URIs"));
  gtk_box_pack_start((GtkBox*)vbox, save_uris_check, FALSE, FALSE, 0);
  hyperlinks_check = gtk_check_button_new_with_mnemonic(_("Capture _hyperlinks only"));
  gtk_box_pack_start((GtkBox*)vbox, hyperlinks_check, FALSE, FALSE, 0);
  confirm_check = gtk_check_button_new_with_mnemonic(_("C_onfirm before clearing history"));
  gtk_box_pack_start((GtkBox*)vbox, confirm_check, FALSE, FALSE, 0);
  use_rmb_menu_check = gtk_check_button_new_with_mnemonic(_("_Use right-click menu"));
  gtk_box_pack_start((GtkBox*)vbox, use_rmb_menu_check, FALSE, FALSE, 0);
  hbox = gtk_hbox_new(FALSE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  gtk_box_pack_start((GtkBox*)vbox_settings, frame, FALSE, FALSE, 0);

  /* Build the history page */
  GtkWidget* page_history = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)page_history, 12, 6, 12, 6);
  gtk_notebook_append_page((GtkNotebook*)notebook, page_history, gtk_label_new(_("History")));
  GtkWidget* vbox_history = gtk_vbox_new(FALSE, 12);
  gtk_container_add((GtkContainer*)page_history, vbox_history);

  /* Build the history frame */
  frame = gtk_frame_new(NULL);
  gtk_frame_set_shadow_type((GtkFrame*)frame, GTK_SHADOW_NONE);
  label = gtk_label_new(NULL);
  gtk_label_set_markup((GtkLabel*)label, _("<b>History</b>"));
  gtk_frame_set_label_widget((GtkFrame*)frame, label);
  alignment = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)alignment, 12, 0, 12, 0);
  gtk_container_add((GtkContainer*)frame, alignment);
  vbox = gtk_vbox_new(FALSE, 2);
  gtk_container_add((GtkContainer*)alignment, vbox);
  save_check = gtk_check_button_new_with_mnemonic(_("Save _history"));
  gtk_widget_set_tooltip_text(save_check, _("Save and restore history between sessions"));
  gtk_box_pack_start((GtkBox*)vbox, save_check, FALSE, FALSE, 0);
  hbox = gtk_hbox_new(FALSE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Items in history:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, FALSE, FALSE, 0);
  adjustment = gtk_adjustment_new(25, 5, 1000, 1, 10, 0);
  history_spin = gtk_spin_button_new((GtkAdjustment*)adjustment, 0.0, 0);
  gtk_spin_button_set_update_policy((GtkSpinButton*)history_spin, GTK_UPDATE_IF_VALID);
  gtk_box_pack_start((GtkBox*)hbox, history_spin, FALSE, FALSE, 0);
  hbox = gtk_hbox_new(FALSE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Items in menu:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, FALSE, FALSE, 0);
  adjustment_small = gtk_adjustment_new(25, 5, 100, 1, 10, 0);
  items_menu = gtk_spin_button_new((GtkAdjustment*)adjustment_small, 0.0, 0);
  gtk_spin_button_set_update_policy((GtkSpinButton*)items_menu, GTK_UPDATE_IF_VALID);
  gtk_box_pack_start((GtkBox*)hbox, items_menu, FALSE, FALSE, 0);
  statics_show_check = gtk_check_button_new_with_mnemonic(_("Show _static items in menu"));
  g_signal_connect((GObject*)statics_show_check, "toggled", (GCallback)check_toggled, NULL);
  gtk_box_pack_start((GtkBox*)vbox, statics_show_check, FALSE, FALSE, 0);
  hbox = gtk_hbox_new(FALSE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Static items in menu:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, FALSE, FALSE, 0);
  adjustment_statics = gtk_adjustment_new(10, 1, 100, 1, 10, 0);
  statics_items_spin = gtk_spin_button_new((GtkAdjustment*)adjustment_statics, 0.0, 0);
  gtk_spin_button_set_update_policy((GtkSpinButton*)statics_items_spin, GTK_UPDATE_IF_VALID);
  gtk_box_pack_start((GtkBox*)hbox, statics_items_spin, FALSE, FALSE, 0);
  gtk_box_pack_start((GtkBox*)vbox_history, frame, FALSE, FALSE, 0);

  /* Build the items frame */
  frame = gtk_frame_new(NULL);
  gtk_frame_set_shadow_type((GtkFrame*)frame, GTK_SHADOW_NONE);
  label = gtk_label_new(NULL);
  gtk_label_set_markup((GtkLabel*)label, _("<b>Items</b>"));
  gtk_frame_set_label_widget((GtkFrame*)frame, label);
  alignment = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)alignment, 12, 0, 12, 0);
  gtk_container_add((GtkContainer*)frame, alignment);
  vbox = gtk_vbox_new(FALSE, 2);
  gtk_container_add((GtkContainer*)alignment, vbox);
  linemode_check = gtk_check_button_new_with_mnemonic(_("Show in a single _line"));
  gtk_box_pack_start((GtkBox*)vbox, linemode_check, FALSE, FALSE, 0);
  reverse_check = gtk_check_button_new_with_mnemonic(_("Show in _reverse order"));
  gtk_box_pack_start((GtkBox*)vbox, reverse_check, FALSE, FALSE, 0);
  hbox = gtk_hbox_new(FALSE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Character length of items:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, FALSE, FALSE, 0);
  adjustment = gtk_adjustment_new(50, 25, 75, 1, 5, 0);
  charlength_spin = gtk_spin_button_new((GtkAdjustment*)adjustment, 0.0, 0);
  gtk_spin_button_set_update_policy((GtkSpinButton*)charlength_spin, GTK_UPDATE_IF_VALID);
  gtk_box_pack_start((GtkBox*)hbox, charlength_spin, FALSE, FALSE, 0);
  hbox = gtk_hbox_new(FALSE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Omit items in the:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, FALSE, FALSE, 0);
  ellipsize_combo = gtk_combo_box_new_text();
  gtk_combo_box_append_text((GtkComboBox*)ellipsize_combo, _("Beginning"));
  gtk_combo_box_append_text((GtkComboBox*)ellipsize_combo, _("Middle"));
  gtk_combo_box_append_text((GtkComboBox*)ellipsize_combo, _("End"));
  gtk_box_pack_start((GtkBox*)hbox, ellipsize_combo, FALSE, FALSE, 0);
  gtk_box_pack_start((GtkBox*)vbox_history, frame, FALSE, FALSE, 0);
  
  /* Build the omitting frame 
  frame = gtk_frame_new(NULL);
  gtk_frame_set_shadow_type((GtkFrame*)frame, GTK_SHADOW_NONE);
  label = gtk_label_new(NULL);
  gtk_label_set_markup((GtkLabel*)label, _("<b>Omitting</b>"));
  gtk_frame_set_label_widget((GtkFrame*)frame, label);
  alignment = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)alignment, 12, 0, 12, 0);
  gtk_container_add((GtkContainer*)frame, alignment);
  vbox = gtk_vbox_new(FALSE, 2);
  gtk_container_add((GtkContainer*)alignment, vbox);
  hbox = gtk_hbox_new(FALSE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Omit items in the:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, FALSE, FALSE, 0);
  ellipsize_combo = gtk_combo_box_new_text();
  gtk_combo_box_append_text((GtkComboBox*)ellipsize_combo, _("Beginning"));
  gtk_combo_box_append_text((GtkComboBox*)ellipsize_combo, _("Middle"));
  gtk_combo_box_append_text((GtkComboBox*)ellipsize_combo, _("End"));
  gtk_box_pack_start((GtkBox*)hbox, ellipsize_combo, FALSE, FALSE, 0);
  gtk_box_pack_start((GtkBox*)vbox_history, frame, FALSE, FALSE, 0); */
  
  /* Build the actions page */
  GtkWidget* page_actions = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)page_actions, 6, 6, 6, 6);
  gtk_notebook_append_page((GtkNotebook*)notebook, page_actions, gtk_label_new(_("Actions")));
  GtkWidget* vbox_actions = gtk_vbox_new(FALSE, 6);
  gtk_container_add((GtkContainer*)page_actions, vbox_actions);
  
  /* Build the actions label */
  label = gtk_label_new(_("Control-click ClipIt\'s tray icon to use actions"));
  gtk_label_set_line_wrap((GtkLabel*)label, TRUE);
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)vbox_actions, label, FALSE, FALSE, 0);
  
  /* Build the actions treeview */
  GtkWidget* scrolled_window = gtk_scrolled_window_new(
                               (GtkAdjustment*)gtk_adjustment_new(0, 0, 0, 0, 0, 0),
                               (GtkAdjustment*)gtk_adjustment_new(0, 0, 0, 0, 0, 0));
  
  gtk_scrolled_window_set_policy((GtkScrolledWindow*)scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type((GtkScrolledWindow*)scrolled_window, GTK_SHADOW_ETCHED_OUT);
  GtkWidget* treeview = gtk_tree_view_new();
  gtk_tree_view_set_reorderable((GtkTreeView*)treeview, TRUE);
  gtk_tree_view_set_rules_hint((GtkTreeView*)treeview, TRUE);
  actions_list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING, -1);
  gtk_tree_view_set_model((GtkTreeView*)treeview, (GtkTreeModel*)actions_list);
  GtkCellRenderer* name_renderer = gtk_cell_renderer_text_new();
  g_object_set(name_renderer, "editable", TRUE, NULL);
  g_signal_connect((GObject*)name_renderer, "edited", (GCallback)edit_action, (gpointer)0);
  tree_column = gtk_tree_view_column_new_with_attributes(_("Action"), name_renderer, "text", 0, NULL);
  gtk_tree_view_column_set_resizable(tree_column, TRUE);
  gtk_tree_view_append_column((GtkTreeView*)treeview, tree_column);
  GtkCellRenderer* command_renderer = gtk_cell_renderer_text_new();
  g_object_set(command_renderer, "editable", TRUE, NULL);
  g_object_set(command_renderer, "ellipsize-set", TRUE, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
  g_signal_connect((GObject*)command_renderer, "edited", (GCallback)edit_action, (gpointer)1);
  tree_column = gtk_tree_view_column_new_with_attributes(_("Command"), command_renderer, "text", 1, NULL);
  gtk_tree_view_column_set_expand(tree_column, TRUE);
  gtk_tree_view_append_column((GtkTreeView*)treeview, tree_column);
  gtk_container_add((GtkContainer*)scrolled_window, treeview);
  gtk_box_pack_start((GtkBox*)vbox_actions, scrolled_window, TRUE, TRUE, 0);
  
  /* Edit selection and connect treeview related signals */
  actions_selection = gtk_tree_view_get_selection((GtkTreeView*)treeview);
  gtk_tree_selection_set_mode(actions_selection, GTK_SELECTION_BROWSE);
  g_signal_connect((GObject*)treeview, "key-press-event", (GCallback)delete_key_pressed, NULL);
  
  /* Build the buttons */
  GtkWidget* hbbox = gtk_hbutton_box_new();
  gtk_box_set_spacing((GtkBox*)hbbox, 6);
  gtk_button_box_set_layout((GtkButtonBox*)hbbox, GTK_BUTTONBOX_START);
  GtkWidget* add_button = gtk_button_new_with_label(_("Add..."));
  gtk_button_set_image((GtkButton*)add_button, gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
  g_signal_connect((GObject*)add_button, "clicked", (GCallback)add_action, NULL);
  gtk_box_pack_start((GtkBox*)hbbox, add_button, FALSE, TRUE, 0);
  GtkWidget* remove_button = gtk_button_new_with_label(_("Remove"));
  gtk_button_set_image((GtkButton*)remove_button, gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
  g_signal_connect((GObject*)remove_button, "clicked", (GCallback)remove_action, NULL);
  gtk_box_pack_start((GtkBox*)hbbox, remove_button, FALSE, TRUE, 0);
  GtkWidget* up_button = gtk_button_new();
  gtk_button_set_image((GtkButton*)up_button, gtk_image_new_from_stock(GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU));
  g_signal_connect((GObject*)up_button, "clicked", (GCallback)move_action_up, NULL);
  gtk_box_pack_start((GtkBox*)hbbox, up_button, FALSE, TRUE, 0);
  GtkWidget* down_button = gtk_button_new();
  gtk_button_set_image((GtkButton*)down_button, gtk_image_new_from_stock(GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_MENU));
  g_signal_connect((GObject*)down_button, "clicked", (GCallback)move_action_down, NULL);
  gtk_box_pack_start((GtkBox*)hbbox, down_button, FALSE, TRUE, 0);
  gtk_box_pack_start((GtkBox*)vbox_actions, hbbox, FALSE, FALSE, 0);

  /* Build the exclude page */
  GtkWidget* page_exclude = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)page_exclude, 6, 6, 6, 6);
  gtk_notebook_append_page((GtkNotebook*)notebook, page_exclude, gtk_label_new(_("Exclude")));
  GtkWidget* vbox_exclude = gtk_vbox_new(FALSE, 6);
  gtk_container_add((GtkContainer*)page_exclude, vbox_exclude);
  
  /* Build the exclude label */
  label = gtk_label_new(_("Regex list of items that should not be inserted into the history (passwords/sites that you don't need in history, etc)."));
  gtk_label_set_line_wrap((GtkLabel*)label, TRUE);
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)vbox_exclude, label, FALSE, FALSE, 0);
  
  /* Build the exclude treeview */
  GtkWidget* scrolled_window_exclude = gtk_scrolled_window_new(
                               (GtkAdjustment*)gtk_adjustment_new(0, 0, 0, 0, 0, 0),
                               (GtkAdjustment*)gtk_adjustment_new(0, 0, 0, 0, 0, 0));
  
  gtk_scrolled_window_set_policy((GtkScrolledWindow*)scrolled_window_exclude, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type((GtkScrolledWindow*)scrolled_window_exclude, GTK_SHADOW_ETCHED_OUT);
  GtkWidget* treeview_exclude = gtk_tree_view_new();
  gtk_tree_view_set_reorderable((GtkTreeView*)treeview_exclude, TRUE);
  gtk_tree_view_set_rules_hint((GtkTreeView*)treeview_exclude, TRUE);
  exclude_list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING, -1);
  gtk_tree_view_set_model((GtkTreeView*)treeview_exclude, (GtkTreeModel*)exclude_list);
  GtkCellRenderer* name_renderer_exclude = gtk_cell_renderer_text_new();
  g_object_set(name_renderer_exclude, "editable", TRUE, NULL);
  g_signal_connect((GObject*)name_renderer_exclude, "edited", (GCallback)edit_exclude, (gpointer)0);
  tree_column = gtk_tree_view_column_new_with_attributes(_("Regex"), name_renderer_exclude, "text", 0, NULL);
  gtk_tree_view_column_set_resizable(tree_column, TRUE);
  gtk_tree_view_append_column((GtkTreeView*)treeview_exclude, tree_column);
  gtk_container_add((GtkContainer*)scrolled_window_exclude, treeview_exclude);
  gtk_box_pack_start((GtkBox*)vbox_exclude, scrolled_window_exclude, TRUE, TRUE, 0);
  
  /* Edit selection and connect treeview related signals */
  exclude_selection = gtk_tree_view_get_selection((GtkTreeView*)treeview_exclude);
  gtk_tree_selection_set_mode(exclude_selection, GTK_SELECTION_BROWSE);
  g_signal_connect((GObject*)treeview_exclude, "key-press-event", (GCallback)delete_key_pressed, NULL);
  
  /* Build the buttons */
  GtkWidget* hbbox_exclude = gtk_hbutton_box_new();
  gtk_box_set_spacing((GtkBox*)hbbox_exclude, 6);
  gtk_button_box_set_layout((GtkButtonBox*)hbbox_exclude, GTK_BUTTONBOX_START);
  GtkWidget* add_button_exclude = gtk_button_new_with_label(_("Add..."));
  gtk_button_set_image((GtkButton*)add_button_exclude, gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
  g_signal_connect((GObject*)add_button_exclude, "clicked", (GCallback)add_exclude, NULL);
  gtk_box_pack_start((GtkBox*)hbbox_exclude, add_button_exclude, FALSE, TRUE, 0);
  GtkWidget* remove_button_exclude = gtk_button_new_with_label(_("Remove"));
  gtk_button_set_image((GtkButton*)remove_button_exclude, gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
  g_signal_connect((GObject*)remove_button_exclude, "clicked", (GCallback)remove_exclude, NULL);
  gtk_box_pack_start((GtkBox*)hbbox_exclude, remove_button_exclude, FALSE, TRUE, 0);
  gtk_box_pack_start((GtkBox*)vbox_exclude, hbbox_exclude, FALSE, FALSE, 0);
  
  /* Build the hotkeys page */
  GtkWidget* page_extras = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)page_extras, 12, 6, 12, 6);
  gtk_notebook_append_page((GtkNotebook*)notebook, page_extras, gtk_label_new(_("Hotkeys")));
  GtkWidget* vbox_extras = gtk_vbox_new(FALSE, 12);
  gtk_container_add((GtkContainer*)page_extras, vbox_extras);
  
  /* Build the hotkeys frame */
  frame = gtk_frame_new(NULL);
  gtk_frame_set_shadow_type((GtkFrame*)frame, GTK_SHADOW_NONE);
  label = gtk_label_new(NULL);
  gtk_label_set_markup((GtkLabel*)label, _("<b>Hotkeys</b>"));
  gtk_frame_set_label_widget((GtkFrame*)frame, label);
  alignment = gtk_alignment_new(0.50, 0.50, 1.0, 1.0);
  gtk_alignment_set_padding((GtkAlignment*)alignment, 12, 0, 12, 0);
  gtk_container_add((GtkContainer*)frame, alignment);
  vbox = gtk_vbox_new(FALSE, 2);
  gtk_container_add((GtkContainer*)alignment, vbox);
  /* History key combination */
  hbox = gtk_hbox_new(TRUE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("History hotkey:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, TRUE, TRUE, 0);
  history_key_entry = gtk_entry_new();
  gtk_entry_set_width_chars((GtkEntry*)history_key_entry, 10);
  gtk_box_pack_end((GtkBox*)hbox, history_key_entry, TRUE, TRUE, 0);
  /* Actions key combination */
  hbox = gtk_hbox_new(TRUE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Actions hotkey:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, TRUE, TRUE, 0);
  actions_key_entry = gtk_entry_new();
  gtk_entry_set_width_chars((GtkEntry*)actions_key_entry, 10);
  gtk_box_pack_end((GtkBox*)hbox, actions_key_entry, TRUE, TRUE, 0);
  /* Menu key combination */
  hbox = gtk_hbox_new(TRUE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Menu hotkey:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, TRUE, TRUE, 0);
  menu_key_entry = gtk_entry_new();
  gtk_entry_set_width_chars((GtkEntry*)menu_key_entry, 10);
  gtk_box_pack_end((GtkBox*)hbox, menu_key_entry, TRUE, TRUE, 0);
  /* Search key combination */
  hbox = gtk_hbox_new(TRUE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Manage hotkey:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, TRUE, TRUE, 0);
  search_key_entry = gtk_entry_new();
  gtk_entry_set_width_chars((GtkEntry*)search_key_entry, 10);
  gtk_box_pack_end((GtkBox*)hbox, search_key_entry, TRUE, TRUE, 0);
  /* Offline mode key combination */
  hbox = gtk_hbox_new(TRUE, 4);
  gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0);
  label = gtk_label_new(_("Offline mode hotkey:"));
  gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50);
  gtk_box_pack_start((GtkBox*)hbox, label, TRUE, TRUE, 0);
  offline_key_entry = gtk_entry_new();
  gtk_entry_set_width_chars((GtkEntry*)offline_key_entry, 10);
  gtk_box_pack_end((GtkBox*)hbox, offline_key_entry, TRUE, TRUE, 0);
  gtk_box_pack_start((GtkBox*)vbox_extras, frame, FALSE, FALSE, 0);
  
  /* Make widgets reflect current preferences */
  gtk_toggle_button_set_active((GtkToggleButton*)copy_check, prefs.use_copy);
  gtk_toggle_button_set_active((GtkToggleButton*)primary_check, prefs.use_primary);
  gtk_toggle_button_set_active((GtkToggleButton*)synchronize_check, prefs.synchronize);
  gtk_toggle_button_set_active((GtkToggleButton*)paste_check, prefs.automatic_paste);
  gtk_toggle_button_set_active((GtkToggleButton*)show_indexes_check, prefs.show_indexes);
  gtk_toggle_button_set_active((GtkToggleButton*)save_uris_check, prefs.save_uris);
  gtk_toggle_button_set_active((GtkToggleButton*)use_rmb_menu_check, prefs.use_rmb_menu);
  gtk_toggle_button_set_active((GtkToggleButton*)save_check, prefs.save_history);
  gtk_spin_button_set_value((GtkSpinButton*)history_spin, (gdouble)prefs.history_limit);
  gtk_spin_button_set_value((GtkSpinButton*)items_menu, (gdouble)prefs.items_menu);
  gtk_toggle_button_set_active((GtkToggleButton*)statics_show_check, prefs.statics_show);
  gtk_spin_button_set_value((GtkSpinButton*)statics_items_spin, (gdouble)prefs.statics_items);
  gtk_toggle_button_set_active((GtkToggleButton*)hyperlinks_check, prefs.hyperlinks_only);
  gtk_toggle_button_set_active((GtkToggleButton*)confirm_check, prefs.confirm_clear);
  gtk_toggle_button_set_active((GtkToggleButton*)linemode_check, prefs.single_line);
  gtk_toggle_button_set_active((GtkToggleButton*)reverse_check, prefs.reverse_history);
  gtk_spin_button_set_value((GtkSpinButton*)charlength_spin, (gdouble)prefs.item_length);
  gtk_combo_box_set_active((GtkComboBox*)ellipsize_combo, prefs.ellipsize - 1);
  gtk_entry_set_text((GtkEntry*)history_key_entry, prefs.history_key);
  gtk_entry_set_text((GtkEntry*)actions_key_entry, prefs.actions_key);
  gtk_entry_set_text((GtkEntry*)menu_key_entry, prefs.menu_key);
  gtk_entry_set_text((GtkEntry*)search_key_entry, prefs.search_key);
  gtk_entry_set_text((GtkEntry*)offline_key_entry, prefs.offline_key);
  
  /* Read actions */
  read_actions();
  read_excludes();
  
  /* Run the dialog */
  gtk_widget_show_all(dialog);
#ifdef HAVE_APPINDICATOR
  gtk_widget_hide(use_rmb_menu_check);
#endif
  gtk_notebook_set_current_page((GtkNotebook*)notebook, tab);
  if (gtk_dialog_run((GtkDialog*)dialog) == GTK_RESPONSE_ACCEPT)
  {
    /* If the user disabled history saving, we ask him if he wants to delete the history file */
    if(prefs.save_history && !gtk_toggle_button_get_active((GtkToggleButton*)save_check))
      check_saved_hist_file();
    /* Apply and save preferences */
    apply_preferences();
    save_preferences();
    save_actions();
    save_excludes();
  }
  gtk_widget_destroy(dialog);
}
Exemplo n.º 20
0
void ctree_refresh(void)
{
	GtkTreeView *view = GTK_TREE_VIEW(ctree_wnd);
	GtkTreeViewColumn *col;
	GdkPixbuf *pix1, *pix2, *pix3, *pix4, *pix5, *pix6;
	GdkPixbuf *pix9 = NULL;
	GtkTreeIter parent_node;
	GtkTreeIter child_node;
	GtkIconTheme *theme;
	GNode *vars, *apps;
	int i, j;

	if (remote.var_tree == NULL)
		return;

	if(working_mode & MODE_CMD)
		return;

	// sort variables
	for(i = 0; i < CTREE_NVCOLS; i++)
	{
		col = gtk_tree_view_get_column(view, i);
		gtk_tree_view_column_set_sort_indicator(col, FALSE);
	}

	switch (options.remote_sort) 
	{
	case SORT_BY_NAME:
		tilp_vars_sort_by_name();
		col = gtk_tree_view_get_column(view, COLUMN_NAME);
		gtk_tree_view_column_set_sort_indicator(col, TRUE);
		gtk_tree_view_column_set_sort_order(col, options.remote_sort_order ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
		break;
	case SORT_BY_INFO:
		tilp_vars_sort_by_info();
		col = gtk_tree_view_get_column(view, COLUMN_ATTR);
		gtk_tree_view_column_set_sort_indicator(col, TRUE);
		gtk_tree_view_column_set_sort_order(col, options.remote_sort_order ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
		break;
	case SORT_BY_TYPE:
		tilp_vars_sort_by_type();
		col = gtk_tree_view_get_column(view, COLUMN_TYPE);
		gtk_tree_view_column_set_sort_indicator(col, TRUE);
		gtk_tree_view_column_set_sort_order(col, options.remote_sort_order ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
		break;
	case SORT_BY_SIZE:
		tilp_vars_sort_by_size();
		col = gtk_tree_view_get_column(view, COLUMN_SIZE);
		gtk_tree_view_column_set_sort_indicator(col, TRUE);
		gtk_tree_view_column_set_sort_order(col, options.remote_sort_order ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
		break;
	}

	// place base nodes
	ctree_set_basetree();
	memcpy(&parent_node, &vars_node, sizeof(GtkTreeIter));

	// load pixmaps
	theme = gtk_icon_theme_get_default();
	pix1 = gtk_widget_render_icon(GTK_WIDGET(view), GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU, NULL);
	pix2 = create_pixbuf("TIicon2.ico");
	pix3 = gtk_icon_theme_load_icon(theme, "folder-open", 16, 0, NULL);
	if (pix3 == NULL)
	{
		pix3 = create_pixbuf("ctree_open_dir.png");
	}
	pix4 = gtk_icon_theme_load_icon(theme, "emblem-readonly", 16, 0, NULL);
	if (pix4 == NULL)
	{
		pix4 = create_pixbuf("attr_locked.png");
	}
	pix5 = gtk_icon_theme_load_icon(theme, "emblem-system", 16, 0, NULL);
	if (pix5 == NULL)
	{
		pix5 = create_pixbuf("attr_archived.png");
	}
	pix6 = create_pixbuf("TIicon4.ico");

	// variables tree
	vars = remote.var_tree;
	for (i = 0; i < (int)g_node_n_children(vars); i++) 
	{
		GNode *parent = g_node_nth_child(vars, i);
		VarEntry *fe = (VarEntry *) (parent->data);

		if ((fe != NULL) || (ticalcs_calc_features(calc_handle) & FTS_FOLDER)) 
		{
			char *utf8 = ticonv_varname_to_utf8(options.calc_model, fe->name, -1);

			gtk_tree_store_append(tree, &parent_node, &vars_node);
			gtk_tree_store_set(tree, &parent_node, 
					   COLUMN_NAME, utf8, 
					   COLUMN_DATA, (gpointer) fe,
					   COLUMN_ICON, pix1, -1);
			g_free(utf8);
		}

		for (j = 0; j < (int)g_node_n_children(parent); j++) 
		{
			GNode *node = g_node_nth_child(parent, j);
			gchar **row_text = g_malloc0((CTREE_NCOLS + 1) * sizeof(gchar *));
			VarEntry *ve = (VarEntry *) (node->data);
			char icon_name[256];

			row_text[0] = ticonv_varname_to_utf8(options.calc_model, ve->name, ve->type);
			row_text[2] = g_strdup_printf("%s", tifiles_vartype2string(options.calc_model, ve->type));
			tilp_var_get_size(ve, &row_text[3]);

			strcpy(icon_name, tifiles_vartype2icon(options.calc_model, ve->type));
			strcat(icon_name, ".ico");
			tilp_file_underscorize(icon_name);
			pix9 = create_pixbuf(icon_name);

			// ticonv wrapper
			tilp_vars_translate(row_text[0]);

			gtk_tree_store_append(tree, &child_node, &parent_node);
			gtk_tree_store_set(tree, &child_node, COLUMN_NAME,
					   row_text[0],
					   COLUMN_TYPE,
					   row_text[2], COLUMN_SIZE,
					   row_text[3], COLUMN_DATA,
					   (gpointer) ve, COLUMN_ICON, pix9,
					   COLUMN_FONT, FONT_NAME,
					   -1);

			switch (ve->attr) 
			{
			case ATTRB_LOCKED:
				gtk_tree_store_set(tree, &child_node, COLUMN_ATTR, pix4, -1);
				break;
			case ATTRB_ARCHIVED:
				gtk_tree_store_set(tree, &child_node, COLUMN_ATTR, pix5, -1);
				break;
			default:
				break;
			}
			g_object_unref(pix9);
			g_strfreev(row_text);
		}
	}

	// Appplications tree
	apps = remote.app_tree;
	for (i = 0; i < (int)g_node_n_children(apps); i++) 
	{
		GNode *parent = g_node_nth_child(apps, i);

		for (j = 0; j < (int)g_node_n_children(parent); j++) 
		{
			GNode *node = g_node_nth_child(parent, j);
			gchar **row_text = g_malloc0((CTREE_NCOLS + 1) * sizeof(gchar *));
			VarEntry *ve = (VarEntry *) (node->data);
			char icon_name[256];

			row_text[0] = ticonv_varname_to_utf8(options.calc_model, ve->name, ve->type);
			row_text[2] = g_strdup_printf("%s", tifiles_vartype2string(options.calc_model, ve->type));
			row_text[3] = g_strdup_printf("%u", (int) (ve->size));

			strcpy(icon_name, tifiles_vartype2icon(options.calc_model, ve->type));
			strcat(icon_name, ".ico");
			tilp_file_underscorize(icon_name);
			pix9 = create_pixbuf(icon_name);

			gtk_tree_store_append(tree, &child_node, &apps_node);
			gtk_tree_store_set(tree, &child_node, 
					COLUMN_NAME, row_text[0], 
					COLUMN_TYPE, row_text[2],
					COLUMN_SIZE, row_text[3], 
					COLUMN_DATA, (gpointer) ve, 
					COLUMN_ICON, pix9,
					COLUMN_FONT, FONT_NAME,
					   -1);
			g_object_unref(pix9);
			g_strfreev(row_text);
		}
	}
	gtk_tree_view_expand_all(GTK_TREE_VIEW(ctree_wnd));

	g_object_unref(pix1);
	g_object_unref(pix2);
	g_object_unref(pix3);
	g_object_unref(pix4);
	g_object_unref(pix5);
	g_object_unref(pix6);

	tilp_remote_selection_destroy();
}
Exemplo n.º 21
0
static void tb_editor_set_item_values(TBEditorWidget *tbw, const gchar *action_name,
                                      GtkListStore *store, GtkTreeIter *iter)
{
    gchar *icon = NULL;
    gchar *label = NULL;
    gchar *label_clean = NULL;
    GdkPixbuf *pix = NULL;
    GtkAction *action;

    action = gtk_action_group_get_action(marlin_view_window_get_actiongroup(tbw->mvw), action_name);

    if (action != NULL)
    {
        /*gtk_action_block_activate(action);
          log_printf (LOG_LEVEL_UNDEFINED, "blocked %s\n", action_name);*/
        icon = katze_object_get_string(action, "icon-name");
        if (icon == NULL)
        {
            icon = katze_object_get_string(action, "stock-id");
        }

        label = katze_object_get_string(action, "label");
        if (label != NULL)
            label_clean = katze_strip_mnemonics(label);
    }
    else
        label_clean = strdup(action_name);


    GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
    /*GtkIconInfo *icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon, 16,
      GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SIZE);
      gchar *test;
      test = gtk_icon_info_get_filename (icon_info);
    //log_printf (LOG_LEVEL_UNDEFINED, "action: %20s icon: %20s\n", action_name, icon);
    log_printf (LOG_LEVEL_UNDEFINED, "action: %20s icon: %20s test: %s\n", action_name, icon, test);*/


    if (icon != NULL)
    {
        //GtkIconSize status_btn_size = gtk_icon_size_from_name ("16px");
        GtkWidget *image = gtk_image_new ();
        //pix = gtk_widget_render_icon (image, icon, status_btn_size, NULL);
        pix = gtk_widget_render_icon (image, icon, GTK_ICON_SIZE_MENU, NULL);
        gtk_widget_destroy (image);

        if (pix==NULL && icon!=NULL)
            pix = gtk_icon_theme_load_icon (icon_theme, icon, 16,
                                            GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
    }

    gtk_list_store_set(store, iter,
                       TB_EDITOR_COL_ACTION, action_name,
                       TB_EDITOR_COL_LABEL, label_clean,
                       //TB_EDITOR_COL_LABEL, action_name,
                       TB_EDITOR_COL_ICON, pix,
                       -1);

    g_free(icon);
    g_free(label);
    g_free(label_clean);
}
Exemplo n.º 22
0
/* Create a menu populated with all subdirectories. */
static GtkWidget * dirmenu_create_menu(DirMenuPlugin * dm, const char * path, gboolean open_at_top)
{
    /* Create a menu. */
    GtkWidget * menu = gtk_menu_new();

    if (dm->folder_icon == NULL)
    {
        int w;
        int h;
        gtk_icon_size_lookup_for_settings(gtk_widget_get_settings(menu), GTK_ICON_SIZE_MENU, &w, &h);
        dm->folder_icon = gtk_icon_theme_load_icon(
            panel_get_icon_theme(dm->panel),
            "gnome-fs-directory", MAX(w, h), 0, NULL);
        if (dm->folder_icon == NULL)
            dm->folder_icon = gtk_widget_render_icon(menu, GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU, NULL);
    }

    g_object_set_data_full(G_OBJECT(menu), "path", g_strdup(path), g_free);

    /* Scan the specified directory to populate the menu with its subdirectories. */
    DirectoryName * dir_list = NULL;
    GDir * dir = g_dir_open(path, 0, NULL);
    if (dir != NULL)
    {
        const char * name;
        while ((name = g_dir_read_name(dir)) != NULL)	/* Memory owned by glib */
        {
            /* Omit hidden files. */
            if (name[0] != '.')
            {
                char * full = g_build_filename(path, name, NULL);
                if (g_file_test(full, G_FILE_TEST_IS_DIR))
                {
                    /* Convert name to UTF-8 and to the collation key. */
                    char * directory_name = g_filename_display_name(name);
                    char * directory_name_collate_key = g_utf8_collate_key(directory_name, -1);

                    /* Locate insertion point. */
                    DirectoryName * dir_pred = NULL;
                    DirectoryName * dir_cursor;
                    for (dir_cursor = dir_list; dir_cursor != NULL; dir_pred = dir_cursor, dir_cursor = dir_cursor->flink)
                    {
                        if (strcmp(directory_name_collate_key, dir_cursor->directory_name_collate_key) <= 0)
                            break;
                    }

                    /* Allocate and initialize sorted directory name entry. */
                    dir_cursor = g_new0(DirectoryName, 1);
                    dir_cursor->directory_name = directory_name;
                    dir_cursor->directory_name_collate_key = directory_name_collate_key;
                    if (dir_pred == NULL)
                    {
                        dir_cursor->flink = dir_list;
                        dir_list = dir_cursor;
                    }
                    else
                    {
                        dir_cursor->flink = dir_pred->flink;
                        dir_pred->flink = dir_cursor;
                    }
                }
                g_free(full);
            }
        }
        g_dir_close(dir);
    }

    /* The sorted directory name list is complete.  Loop to create the menu. */
    DirectoryName * dir_cursor;
    while ((dir_cursor = dir_list) != NULL)
    {
        /* Create and initialize menu item. */
        GtkWidget * item = gtk_image_menu_item_new_with_label(dir_cursor->directory_name);
        gtk_image_menu_item_set_image(
            GTK_IMAGE_MENU_ITEM(item),
            gtk_image_new_from_stock(GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU));
        GtkWidget * dummy = gtk_menu_new();
        gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), dummy);
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);

        /* Unlink and free sorted directory name element, but reuse the directory name string. */
        dir_list = dir_cursor->flink;
        g_object_set_data_full(G_OBJECT(item), "name", dir_cursor->directory_name, g_free);
        g_free(dir_cursor->directory_name_collate_key);
        g_free(dir_cursor);

        /* Connect signals. */
        g_signal_connect(G_OBJECT(item), "select", G_CALLBACK(dirmenu_menuitem_select), dm);
        g_signal_connect(G_OBJECT(item), "deselect", G_CALLBACK(dirmenu_menuitem_deselect), dm);
    }

    /* Create "Open" and "Open in Terminal" items. */
    GtkWidget * item = gtk_image_menu_item_new_from_stock( GTK_STOCK_OPEN, NULL );
    g_signal_connect(item, "activate", G_CALLBACK(dirmenu_menuitem_open_directory), dm);
    GtkWidget * term = gtk_menu_item_new_with_mnemonic( _("Open in _Terminal") );
    g_signal_connect(term, "activate", G_CALLBACK(dirmenu_menuitem_open_in_terminal), dm);

    /* Insert or append based on caller's preference. */
    if (open_at_top)
    {
        gtk_menu_shell_insert(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new(), 0);
        gtk_menu_shell_insert(GTK_MENU_SHELL(menu), term, 0);
        gtk_menu_shell_insert(GTK_MENU_SHELL(menu), item, 0);
    }
    else {
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), term);
        gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
    }

    /* Show the menu and return. */
    gtk_widget_show_all(menu);
    return menu;
}
Exemplo n.º 23
0
static void
configure_item_cursor (GtkToolItem *item,
		       EggEditableToolbar *etoolbar)
{
  EggEditableToolbarPrivate *priv = etoolbar->priv;
  GtkWidget *widget = GTK_WIDGET (item);

  if (gtk_widget_get_window (widget) != NULL)
    {
      if (priv->edit_mode > 0)
        {
          GdkCursor *cursor;
	  GdkScreen *screen;
          GdkPixbuf *pixbuf = NULL;

	  screen = gtk_widget_get_screen (GTK_WIDGET (etoolbar));

          cursor = gdk_cursor_new_for_display (gdk_screen_get_display (screen),
					       GDK_HAND2);
          gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
          gdk_cursor_unref (cursor);

          gtk_drag_source_set (widget, GDK_BUTTON1_MASK, dest_drag_types,
                               G_N_ELEMENTS (dest_drag_types), GDK_ACTION_MOVE);
          if (GTK_IS_SEPARATOR_TOOL_ITEM (item))
            {
              pixbuf = new_separator_pixbuf ();
            }
          else
            {
              char *icon_name=NULL;
              char *stock_id=NULL;
              GtkAction *action;
              char *name;

              name = g_object_get_data (G_OBJECT (widget), EGG_ITEM_NAME);
              action = name ? find_action (etoolbar, name) : NULL;

              if (action)
                {
                   g_object_get (action,
                                 "icon-name", &icon_name,
                                 "stock-id", &stock_id,
                                 NULL);
                }
              if (icon_name)
                {
                  GdkScreen *screen;
                  GtkIconTheme *icon_theme;
                  GtkSettings *settings;
                  gint width, height;

                  screen = gtk_widget_get_screen (widget);
                  icon_theme = gtk_icon_theme_get_for_screen (screen);
                  settings = gtk_settings_get_for_screen (screen);

                  if (!gtk_icon_size_lookup_for_settings (settings,
                                                          GTK_ICON_SIZE_LARGE_TOOLBAR,
                                                          &width, &height))
                    {
                      width = height = 24;
                    }

                  pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name,
                                                     MIN (width, height), 0, NULL);
                }
              else if (stock_id)
                {
                  pixbuf = gtk_widget_render_icon (widget, stock_id,
	                                           GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
                }
              g_free (icon_name);
              g_free (stock_id);
            }

          if (G_UNLIKELY (!pixbuf))
            {
              return;
            }
          gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
          g_object_unref (pixbuf);

        }
      else
        {
          gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET(item)), NULL);
        }
    }
}
Exemplo n.º 24
0
// Updates the images according to preferences and the window situation
// Warning! This function is called very often, so it should only do the most necessary things!
void updateTitle(WTApplet *wtapplet) {
	WnckWindow *controlledwindow;
	gchar *title_text, *title_color, *title_font;
	GdkPixbuf *icon_pixbuf;
	
	if (wtapplet->prefs->only_maximized) {
		controlledwindow = wtapplet->umaxedwindow;
	} else {
		controlledwindow = wtapplet->activewindow;
	}

	if (controlledwindow == NULL)
		return;
	
	if (controlledwindow == wtapplet->rootwindow) {
		// we're on desktop
		if (wtapplet->prefs->hide_on_unmaximized) {
			// hide everything
			icon_pixbuf = NULL;
			title_text = "";
		} else {
			// display "custom" icon/title (TODO: customization via preferences?)
			icon_pixbuf = gtk_widget_render_icon(GTK_WIDGET(wtapplet),GTK_STOCK_HOME,GTK_ICON_SIZE_MENU,NULL); // This has to be unrefed!
			title_text = ("Desktop");
		}
	} else {
		icon_pixbuf = wnck_window_get_icon(controlledwindow); // This only returns a pointer - it SHOULDN'T be unrefed!
		title_text = (gchar*)wnck_window_get_name(controlledwindow);
	}
	
	// TODO: we need the default font to somehow be the same in both modes
	if (wtapplet->prefs->custom_style) {
		// custom style
		if (controlledwindow == wtapplet->activewindow) {
			// window focused
			title_color = wtapplet->prefs->title_active_color;
			title_font = wtapplet->prefs->title_active_font;
		} else {
			// window unfocused
			title_color = wtapplet->prefs->title_inactive_color;
			title_font = wtapplet->prefs->title_inactive_font;	
		}
	} else {
		// automatic (non-custom) style
		if (controlledwindow == wtapplet->activewindow) {
			// window focused				
			title_color = wtapplet->panel_color_fg;
			title_font = "";
		} else {
			// window unfocused
			title_color = "#808080"; // inactive title color. best fits for any panel regardless of color
			title_font = "";
		}		
	}

	// Set tooltips
	if (wtapplet->prefs->show_tooltips) {
		gtk_widget_set_tooltip_text (GTK_WIDGET(wtapplet->icon), title_text);
		gtk_widget_set_tooltip_text (GTK_WIDGET(wtapplet->title), title_text);
	}

	title_text = g_markup_printf_escaped("<span font=\"%s\" color=\"%s\">%s</span>", title_font, title_color, title_text);
	// Apply markup to label widget
	gtk_label_set_markup(GTK_LABEL(wtapplet->title), title_text);
	g_free(title_text);

	if (icon_pixbuf == NULL) {
		gtk_image_clear(wtapplet->icon);
	} else {
		// We're updating window info (Careful! We've had pixbuf memory leaks here)
		GdkPixbuf *ipb1 = gdk_pixbuf_scale_simple(icon_pixbuf, ICON_WIDTH, ICON_HEIGHT, GDK_INTERP_BILINEAR);
		if (controlledwindow == wtapplet->rootwindow) g_object_unref(icon_pixbuf); //this is stupid beyond belief, thanks to the retarded GTK framework
		GdkPixbuf *ipb2 = gdk_pixbuf_rotate_simple(ipb1, wtapplet->angle);
		g_object_unref(ipb1);	// Unref ipb1 to get it cleared from memory (we still need ipb2)

		// Saturate icon when window is not focused
		if (controlledwindow != wtapplet->activewindow) 
			gdk_pixbuf_saturate_and_pixelate(ipb2, ipb2, 0, FALSE);
		
		// Apply pixbuf to icon widget
		gtk_image_set_from_pixbuf(wtapplet->icon, ipb2);
		g_object_unref(ipb2);   // Unref ipb2 to get it cleared from memory			
	}
}
Exemplo n.º 25
0
gboolean _gx_knob_pointer_event(GtkWidget *widget, gdouble x, gdouble y, const gchar *icon,
                                gboolean drag, int state, int button, GdkEventButton *event)
{
	int fcount;
	bool finemode = ((state & (GDK_CONTROL_MASK|GDK_SHIFT_MASK)) != 0);
	GdkRectangle image_rect, value_rect;
	
	GxKnob *knob = GX_KNOB(widget);
	GdkPixbuf *pb = gtk_widget_render_icon(widget, icon, GtkIconSize(-1), NULL);
	GxKnobPrivate *priv = knob->priv;
	
	get_image_dimensions (widget, pb, &image_rect, &fcount);
	
	g_object_unref(pb);
	x += widget->allocation.x;
	y += widget->allocation.y;
	_gx_regler_get_positions(GX_REGLER(widget), &image_rect, &value_rect);
	if (!drag) {
		if (_gx_regler_check_display_popup(GX_REGLER(widget), &image_rect, &value_rect, event)) {
			return FALSE;
		}
	}
	static double last_y = 2e20;
		GtkAdjustment *adj = gtk_range_get_adjustment(GTK_RANGE(widget));
	double radius =  min(image_rect.width, image_rect.height) / 2;
	double posx = radius - x + image_rect.x; // x axis right -> left
	double posy = radius - y + image_rect.y; // y axis top -> bottom
	double value;
	if (!drag) {
		if (event && event->type == GDK_2BUTTON_PRESS) {
			last_y = 2e20;
		} else {
			last_y = posy;
			return TRUE;
		}
	}
	if (last_y < 1e20) { // in drag started in linear mode
		const double scaling = 0.005;
		double scal = (finemode ? scaling*0.1 : scaling);
		value = (posy - last_y) * scal;
		last_y = posy;
		gtk_range_set_value(GTK_RANGE(widget), adj->value + value * (adj->upper - adj->lower));
		return TRUE;
	}

	double angle = atan2(-posx, posy) + M_PI; // clockwise, zero at 6 o'clock, 0 .. 2*M_PI
	if (drag) {
		// block "forbidden zone" and direct moves between quadrant 1 and 4
		int quadrant = 1 + (int)(angle/M_PI_2);
		if (priv->last_quadrant == 1 && (quadrant == 3 || quadrant == 4)) {
			angle = scale_zero;
		} else if (priv->last_quadrant == 4 && (quadrant == 1 || quadrant == 2)) {
			angle = 2*M_PI - scale_zero;
		} else {
			if (angle < scale_zero) {
				angle = scale_zero;
			} else if (angle > 2*M_PI - scale_zero) {
				angle = 2*M_PI - scale_zero;
			}
			priv->last_quadrant = quadrant;
		}
	} else {
		if (angle < scale_zero) {
			angle = scale_zero;
		} else if (angle > 2*M_PI - scale_zero) {
			angle = 2*M_PI - scale_zero;
		}
		priv->last_quadrant = 0;
	}
	angle = (angle - scale_zero) / (2 * (M_PI-scale_zero)); // normalize to 0..1
	gtk_range_set_value(GTK_RANGE(widget), adj->lower + angle * (adj->upper - adj->lower));
	return TRUE;
}
Exemplo n.º 26
0
gboolean
metadata_dialog (gint32    image_ID,
                 XMPModel *xmp_model)
{
  MetadataGui  mgui;
  GtkWidget   *notebook;

  gimp_ui_init (PLUG_IN_BINARY, FALSE);

  mgui.dlg = gimp_dialog_new (_("Image Properties"), PLUG_IN_ROLE,
                              NULL, 0,
                              gimp_standard_help_func, EDITOR_PROC,

                              _("_Import XMP..."), RESPONSE_IMPORT,
                              _("_Export XMP..."), RESPONSE_EXPORT,
                              GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                              GTK_STOCK_OK,     GTK_RESPONSE_OK,

                              NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (mgui.dlg),
                                           RESPONSE_IMPORT,
                                           RESPONSE_EXPORT,
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  gimp_window_set_transient (GTK_WINDOW (mgui.dlg));

  g_signal_connect (mgui.dlg, "response",
                    G_CALLBACK (metadata_dialog_response),
                    &mgui);
  g_signal_connect (mgui.dlg, "destroy",
                    G_CALLBACK (gtk_main_quit),
                    NULL);

  notebook = gtk_notebook_new ();
  gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
  gtk_container_set_border_width (GTK_CONTAINER (notebook), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (mgui.dlg))),
                      notebook, TRUE, TRUE, 0);
  gtk_widget_show (notebook);

  mgui.xmp_model = xmp_model;
  mgui.edit_icon = gtk_widget_render_icon (mgui.dlg, GTK_STOCK_EDIT,
                                           GTK_ICON_SIZE_MENU, NULL);
  mgui.auto_icon = gtk_widget_render_icon (mgui.dlg, GIMP_STOCK_WILBER,
                                           GTK_ICON_SIZE_MENU, NULL);
  update_icons (&mgui);

  mgui.run_ok = FALSE;

  /* add the tabs to the notebook */
  add_description_tab (notebook, &mgui);
  add_copyright_tab (notebook);
  add_origin_tab (notebook);
  add_camera1_tab (notebook);
  add_camera2_tab (notebook);
  add_thumbnail_tab (notebook);
  add_advanced_tab (notebook, xmp_model_get_tree_model (mgui.xmp_model));

  gtk_window_set_default_size (GTK_WINDOW (mgui.dlg), 400, 500);
  gtk_widget_show (mgui.dlg);

  /* run, baby, run! */
  gtk_main ();

  /* clean up and return */
  g_object_unref (mgui.auto_icon);
  g_object_unref (mgui.edit_icon);

  return mgui.run_ok;
}
Exemplo n.º 27
0
static GdkPixbuf* accessx_status_applet_slowkeys_image(AccessxStatusApplet* sapplet, XkbAccessXNotifyEvent* event)
{
    GdkPixbuf* ret_pixbuf;
    GdkWindow* window;
    gboolean is_idle = TRUE;
    gchar* stock_id = SLOWKEYS_IDLE_ICON;
    GtkStyle* style = gtk_widget_get_style(GTK_WIDGET(sapplet->applet));
    GdkColor bg = style->bg[GTK_STATE_NORMAL];

    if (event != NULL)
    {
        is_idle = FALSE;

        switch (event->detail)
        {
        case XkbAXN_SKPress:
            stock_id = ACCESSX_BASE_ICON;
            if (_sk_timeout)
            {
                g_source_remove(_sk_timeout);
                _sk_timeout = 0;
            }
            break;
        case XkbAXN_SKAccept:
            stock_id = ACCESSX_ACCEPT_BASE;
            gdk_color_parse("#009900", &bg);
            break;
        case XkbAXN_SKReject:
            stock_id = ACCESSX_REJECT_BASE;
            gdk_color_parse("#990000", &bg);
            _sk_timeout = g_timeout_add_full(G_PRIORITY_HIGH_IDLE, MAX(event->sk_delay, 150), timer_reset_slowkeys_image, sapplet->slowfoo, NULL);
            break;
        case XkbAXN_SKRelease:
        default:
            stock_id = SLOWKEYS_IDLE_ICON;
            is_idle = TRUE;
            break;
        }
    }

    ret_pixbuf = gtk_widget_render_icon(GTK_WIDGET(sapplet->applet), stock_id, icon_size_spec, NULL);

    if (!is_idle)
    {
        GdkPixbuf* glyph_pixbuf;
        GdkPixbuf* tmp_pixbuf;
        GdkColor  fg;
        gchar* glyphstring = N_("a");
        tmp_pixbuf = ret_pixbuf;
        ret_pixbuf = gdk_pixbuf_copy(tmp_pixbuf);
        g_object_unref(tmp_pixbuf);

        window = gtk_widget_get_window(GTK_WIDGET(sapplet->applet));

        if (event && window)
        {
            KeySym keysym = XKeycodeToKeysym(GDK_WINDOW_XDISPLAY(window), event->keycode, 0);
            glyphstring = XKeysymToString(keysym);

            if ((!g_utf8_validate(glyphstring, -1, NULL)) || (g_utf8_strlen(glyphstring, -1) > 1))
            {
                glyphstring = "";
            }
        }

#if GTK_CHECK_VERSION (3, 0, 0)
        fg = style->fg[gtk_widget_get_state_flags (GTK_WIDGET (sapplet->applet))];
#else
        fg = style->fg[gtk_widget_get_state(GTK_WIDGET(sapplet->applet))];
#endif
        glyph_pixbuf = accessx_status_applet_get_glyph_pixbuf(sapplet, GTK_WIDGET(sapplet->applet), ret_pixbuf, &fg, &bg, glyphstring);
        gdk_pixbuf_composite(glyph_pixbuf, ret_pixbuf, 0, 0, gdk_pixbuf_get_width(glyph_pixbuf), gdk_pixbuf_get_height(glyph_pixbuf), 0., 0., 1.0, 1.0, GDK_INTERP_NEAREST, 255);
        g_object_unref(glyph_pixbuf);
    }

    return ret_pixbuf;
}
Exemplo n.º 28
0
int
main (int argc, char *argv[])
{
        char           *file;
        char           *uri;
        GdkPixbuf      *icon;
        GtkWidget      *helper;

        gtk_init (&argc, &argv);

        if (!notify_init ("Images Test"))
                exit (1);

        /* Stock icon */
        n = notify_notification_new ("Icon Test",
                                     "Testing stock icon",
                                     "appointment-new",
                                     NULL);

        if (!notify_notification_show (n, NULL)) {
                fprintf (stderr, "failed to send notification\n");
                return 1;
        }

        g_object_unref (G_OBJECT (n));

        file = g_get_current_dir ();
        uri = g_strdup_printf ("file://%s/%s",
                               file,
                               "dewdop_leaf.jpg");

        g_free (file);
        printf ("sending %s\n", uri);

        /* URIs */
        n = notify_notification_new ("Alert!",
                                     "Testing URI icons",
                                     uri,
                                     NULL);

        if (!notify_notification_show (n, NULL)) {
                fprintf (stderr, "failed to send notification\n");
                return 1;
        }

        g_object_unref (G_OBJECT (n));

        /* Raw image */
        n = notify_notification_new ("Raw image test",
                                     "Testing sending raw pixbufs",
                                     NULL,
                                     NULL);

        /*
         * This is just a hack to get a stock icon's pixbuf in a realworld app
         * if you were sending bitmapped data you would know the file location
         * and open it up with a method that could generate a bmp for you
         */
        helper = gtk_button_new ();
        icon = gtk_widget_render_icon (helper,
                                       GTK_STOCK_DIALOG_QUESTION,
                                       GTK_ICON_SIZE_DIALOG,
                                       NULL);
        gtk_widget_destroy (helper);

        notify_notification_set_icon_from_pixbuf (n, icon);
        g_object_unref (G_OBJECT (icon));

        if (!notify_notification_show (n, NULL)) {
                fprintf (stderr, "failed to send notification\n");
                return 1;
        }

        g_object_unref (G_OBJECT (n));

        return 0;
}
Exemplo n.º 29
0
/* Called when About is selected from right-click menu */
static void show_about_dialog(GtkMenuItem *menu_item, gpointer user_data) {
  /* This helps prevent multiple instances */
  if (!gtk_grab_get_current()) {
    const gchar* authors[] = {"Cristian Henzel <*****@*****.**>\n"
				"Gilberto \"Xyhthyx\" Miralla <*****@*****.**>\n"
				"Eugene Nikolsky <*****@*****.**>", NULL};
    const gchar* license =
      "This program is free software; you can redistribute it and/or modify\n"
      "it under the terms of the GNU General Public License as published by\n"
      "the Free Software Foundation; either version 3 of the License, or\n"
      "(at your option) any later version.\n"
      "\n"
      "This program is distributed in the hope that it will be useful,\n"
      "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
      "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
      "GNU General Public License for more details.\n"
      "\n"
      "You should have received a copy of the GNU General Public License\n"
      "along with this program.  If not, see <http://www.gnu.org/licenses/>.";

    /* Create the about dialog */
    GtkWidget* about_dialog = gtk_about_dialog_new();
    gtk_window_set_icon((GtkWindow*)about_dialog,
                        gtk_widget_render_icon(about_dialog, GTK_STOCK_ABOUT, GTK_ICON_SIZE_MENU, NULL));

    gtk_about_dialog_set_name((GtkAboutDialog*)about_dialog, "ClipIt");
    #ifdef HAVE_CONFIG_H
    gtk_about_dialog_set_version((GtkAboutDialog*)about_dialog, VERSION);
    #endif
    gtk_about_dialog_set_comments((GtkAboutDialog*)about_dialog,
                                _("Lightweight GTK+ clipboard manager."));

    gtk_about_dialog_set_website((GtkAboutDialog*)about_dialog,
                                 "http://clipit.rspwn.com/");

    gtk_about_dialog_set_copyright((GtkAboutDialog*)about_dialog, "Copyright (C) 2010-2012 Cristian Henzel");
    gtk_about_dialog_set_authors((GtkAboutDialog*)about_dialog, authors);
    gtk_about_dialog_set_translator_credits ((GtkAboutDialog*)about_dialog,
                                             "Guido Tabbernuk <*****@*****.**>\n"
                                             "Miloš Koutný <*****@*****.**>\n"
                                             "Kim Jensen <*****@*****.**>\n"
                                             "Eckhard M. Jäger <*****@*****.**>\n"
                                             "Michael Stempin <*****@*****.**>\n"
                                             "Benjamin 'sphax3d' Danon <*****@*****.**>\n"
                                             "Németh Tamás <*****@*****.**>\n"
                                             "Davide Truffa <*****@*****.**>\n"
                                             "Jiro Kawada <*****@*****.**>\n"
                                             "Øyvind Sæther <*****@*****.**>\n"
                                             "pankamyk <*****@*****.**>\n"
                                             "Tomasz Rusek <*****@*****.**>\n"
                                             "Phantom X <*****@*****.**>\n"
                                             "Ovidiu D. Niţan <*****@*****.**>\n"
                                             "Alexander Kazancev <*****@*****.**>\n"
                                             "Daniel Nylander <*****@*****.**>\n"
                                             "Hedef Türkçe <*****@*****.**>\n"
                                             "Lyman Li <*****@*****.**>\n"
                                             "Gilberto \"Xyhthyx\" Miralla <*****@*****.**>");

    gtk_about_dialog_set_license((GtkAboutDialog*)about_dialog, license);
    gtk_about_dialog_set_logo_icon_name((GtkAboutDialog*)about_dialog, GTK_STOCK_PASTE);
    /* Run the about dialog */
    gtk_dialog_run((GtkDialog*)about_dialog);
    gtk_widget_destroy(about_dialog);
  } else {
    /* A window is already open, so we present it to the user */
    GtkWidget *toplevel = gtk_widget_get_toplevel(gtk_grab_get_current());
    gtk_window_present((GtkWindow*)toplevel);
  }
}
int
gnetconfig_detect_interfaces (void)
{
	char 			*name = NULL;
	char			*desc = NULL;
	gint			n_if, i, l;
	GtkTreeModel 		*model;
	GtkListStore 		*store;
	GtkTreeIter		iter;
	GdkPixbuf		*yes_pixbuf;
	GdkPixbuf		*no_pixbuf;
	fwnet_interface_t	*interface;
	GList			*iflist = NULL;
	GList			*tlist = NULL;

	n_if = g_list_length (active_profile->interfaces);
	yes_pixbuf = gtk_widget_render_icon (GTK_WIDGET(if_detect_treeview),
					GTK_STOCK_YES,
					GTK_ICON_SIZE_MENU, NULL);
	no_pixbuf = gtk_widget_render_icon (GTK_WIDGET(if_detect_treeview),
					GTK_STOCK_NO,
					GTK_ICON_SIZE_MENU, NULL);
	model = gtk_tree_view_get_model (GTK_TREE_VIEW(if_detect_treeview));
	store = GTK_LIST_STORE (model);
	gtk_list_store_clear (store);
	iflist = fwnet_iflist ();
	if (iflist == NULL)
	{
		gn_error (_("Cannot populate interface list"));
		return 1;
	}
	tlist = iflist;

	for (l=0;l<(g_list_length(iflist)/2);l++)
	{
		name = (char*) tlist->data;
		tlist = g_list_next (tlist);
		desc = (char*) tlist->data;
		tlist = g_list_next (tlist);
		gboolean configured = FALSE;
		
		/* check if the interface is already present in our profile */
		for (i=0;i<n_if;i++)
		{
			interface = g_list_nth_data (active_profile->interfaces, i);
			if (!strcmp(name, interface->name))
			{
				configured = TRUE;
				break;
			}	
		}

		gtk_list_store_append (store, &iter);
		if (configured)
		{
			gtk_list_store_set (store, &iter,
					0, yes_pixbuf,
					1, name,
					2, desc,
					3, _("Configured"),
					4, TRUE, -1);
		}
		else
		{
			gtk_list_store_set (store, &iter,
					0, no_pixbuf,
					1, name,
					2, desc,
					3, _("Not Configured"),
					4, FALSE, -1);
		}
	}
	gtk_window_set_position (GTK_WINDOW(if_detect_dlg), GTK_WIN_POS_CENTER_ON_PARENT);
	gtk_widget_show_all (if_detect_dlg);
	return 0;
}