Esempio n. 1
0
/* construct widget above */
void gui_init(struct dt_imageio_module_storage_t *self)
{
  self->gui_data = g_malloc0(sizeof(dt_storage_facebook_gui_data_t));
  dt_storage_facebook_gui_data_t *ui = self->gui_data;
  ui->facebook_api = fb_api_init();

  self->widget = gtk_vbox_new(FALSE, 0);

  //create labels
  ui->label_album_title = GTK_LABEL(  gtk_label_new( _("title") ) );
  ui->label_album_summary = GTK_LABEL(  gtk_label_new( _("summary") ) );
  ui->label_album_privacy = GTK_LABEL(gtk_label_new(_("privacy")));
  ui->label_status = GTK_LABEL(gtk_label_new(NULL));

  gtk_misc_set_alignment(GTK_MISC(ui->label_album_title), 0.0, 0.5);
  gtk_misc_set_alignment(GTK_MISC(ui->label_album_summary), 0.0, 0.5);
  gtk_misc_set_alignment(GTK_MISC(ui->label_album_privacy), 0.0, 0.5);

  //create entries
  GtkListStore *model_username  = gtk_list_store_new (COMBO_USER_MODEL_NB_COL, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); //text, token, id
  ui->comboBox_username = GTK_COMBO_BOX(gtk_combo_box_new_with_model(GTK_TREE_MODEL(model_username)));
  GtkCellRenderer *p_cell = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (ui->comboBox_username), p_cell, FALSE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (ui->comboBox_username), p_cell, "text", 0, NULL);

  ui->entry_album_title = GTK_ENTRY(gtk_entry_new());
  ui->entry_album_summary = GTK_ENTRY(gtk_entry_new());

  dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(ui->comboBox_username));
  dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(ui->entry_album_title));
  dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(ui->entry_album_summary));

  //retrieve saved accounts
  ui_refresh_users(ui);

  //////// album list /////////
  GtkWidget *albumlist = gtk_hbox_new(FALSE, 0);
  GtkListStore *model_album = gtk_list_store_new (COMBO_ALBUM_MODEL_NB_COL, G_TYPE_STRING, G_TYPE_STRING); //name, id
  ui->comboBox_album = GTK_COMBO_BOX(gtk_combo_box_new_with_model(GTK_TREE_MODEL(model_album)));
  p_cell = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (ui->comboBox_album), p_cell, FALSE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (ui->comboBox_album), p_cell, "text", 0, NULL);

  gtk_widget_set_sensitive(GTK_WIDGET(ui->comboBox_album), FALSE);
  gtk_combo_box_set_row_separator_func(ui->comboBox_album,combobox_separator,ui->comboBox_album,NULL);
  gtk_box_pack_start(GTK_BOX(albumlist), GTK_WIDGET(ui->comboBox_album), TRUE, TRUE, 0);

  ui->comboBox_privacy= GTK_COMBO_BOX(gtk_combo_box_new_text());
  GtkListStore *list_store = gtk_list_store_new (COMBO_ALBUM_MODEL_NB_COL, G_TYPE_STRING, G_TYPE_INT);
  GtkTreeIter iter;
  gtk_list_store_append(list_store, &iter);
  gtk_list_store_set(list_store, &iter, COMBO_PRIVACY_MODEL_NAME_COL, _("only me"), COMBO_PRIVACY_MODEL_VAL_COL, FBALBUM_PRIVACY_SELF, -1);
  gtk_list_store_append(list_store, &iter);
  gtk_list_store_set(list_store, &iter, COMBO_PRIVACY_MODEL_NAME_COL, _("friends"), COMBO_PRIVACY_MODEL_VAL_COL, FBALBUM_PRIVACY_ALL_FRIENDS, -1);
  gtk_list_store_append(list_store, &iter);
  gtk_list_store_set(list_store, &iter, COMBO_PRIVACY_MODEL_NAME_COL, _("public"), COMBO_PRIVACY_MODEL_VAL_COL, FBALBUM_PRIVACY_EVERYONE, -1);
  gtk_list_store_append(list_store, &iter);
  gtk_list_store_set(list_store, &iter, COMBO_PRIVACY_MODEL_NAME_COL, _("friends of friends"), COMBO_PRIVACY_MODEL_VAL_COL, FBALBUM_PRIVACY_FRIENDS_OF_FRIENDS, -1);

  gtk_combo_box_set_model(ui->comboBox_privacy, GTK_TREE_MODEL(list_store));

  gtk_combo_box_set_active(GTK_COMBO_BOX(ui->comboBox_privacy), 1); // Set default permission to private
  ui->button_login = GTK_BUTTON(gtk_button_new_with_label(_("login")));
  ui->connected = FALSE;

  //pack the ui
  ////the auth box
  GtkWidget *hbox_auth = gtk_hbox_new(FALSE,5);
  GtkWidget *vbox_auth_labels=gtk_vbox_new(FALSE,0);
  GtkWidget *vbox_auth_fields=gtk_vbox_new(FALSE,0);
  gtk_box_pack_start(GTK_BOX(hbox_auth), vbox_auth_labels, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(hbox_auth), vbox_auth_fields, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(hbox_auth), TRUE, FALSE, 2);
  gtk_box_pack_start(GTK_BOX(vbox_auth_fields), GTK_WIDGET(ui->comboBox_username), TRUE, FALSE, 2);

  gtk_box_pack_start(GTK_BOX(vbox_auth_labels), GTK_WIDGET(gtk_label_new("")), TRUE, TRUE, 2);
  gtk_box_pack_start(GTK_BOX(vbox_auth_fields), GTK_WIDGET(ui->button_login), TRUE, FALSE, 2);

  gtk_box_pack_start(GTK_BOX(vbox_auth_fields), GTK_WIDGET(albumlist), TRUE, FALSE, 2);

  ////the album creation box
  ui->hbox_album = GTK_BOX(gtk_hbox_new(FALSE,5));
  gtk_widget_set_no_show_all(GTK_WIDGET(ui->hbox_album), TRUE); //hide it by default
  GtkWidget *vbox_album_labels=gtk_vbox_new(FALSE,0);
  GtkWidget *vbox_album_fields=gtk_vbox_new(FALSE,0);
  gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(ui->hbox_album), TRUE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(ui->hbox_album), vbox_album_labels, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(ui->hbox_album), vbox_album_fields, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_album_labels), GTK_WIDGET(ui->label_album_title), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_album_fields), GTK_WIDGET(ui->entry_album_title), TRUE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_album_labels), GTK_WIDGET(ui->label_album_summary), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_album_fields), GTK_WIDGET(ui->entry_album_summary), TRUE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_album_labels), GTK_WIDGET(ui->label_album_privacy), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_album_fields), GTK_WIDGET(ui->comboBox_privacy), TRUE, FALSE, 0);

  //connect buttons to signals
  g_signal_connect(G_OBJECT(ui->button_login), "clicked", G_CALLBACK(ui_login_clicked), (gpointer)ui);
  g_signal_connect(G_OBJECT(ui->comboBox_username), "changed", G_CALLBACK(ui_combo_username_changed), (gpointer)ui);
  g_signal_connect(G_OBJECT(ui->comboBox_album), "changed", G_CALLBACK(ui_combo_album_changed), (gpointer)ui);

  g_object_unref(model_username);
  g_object_unref(model_album);
  g_object_unref(list_store);
}
void themes_init(AppearanceData* data)
{
  GtkWidget *w, *del_button;
  GList *theme_list, *l;
  GtkListStore *theme_store;
  GtkTreeModel *sort_model;
  MateThemeMetaInfo *meta_theme = NULL;
  GtkIconView *icon_view;
  GtkCellRenderer *renderer;
  GtkSettings *settings;
  char *url;

  /* initialise some stuff */
  mate_theme_init ();
  mate_wm_manager_init ();

  data->revert_application_font = NULL;
  data->revert_documents_font = NULL;
  data->revert_desktop_font = NULL;
  data->revert_windowtitle_font = NULL;
  data->revert_monospace_font = NULL;
  data->theme_save_dialog = NULL;
  data->theme_message_area = NULL;
  data->theme_info_icon = NULL;
  data->theme_error_icon = NULL;
  data->theme_custom = mate_theme_meta_info_new ();
  data->theme_icon = gdk_pixbuf_new_from_file (MATECC_PIXMAP_DIR "/theme-thumbnailing.png", NULL);
  data->theme_store = theme_store =
      gtk_list_store_new (NUM_COLS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);

  /* set up theme list */
  theme_list = mate_theme_meta_info_find_all ();
  mate_theme_info_register_theme_change ((ThemeChangedCallback) theme_changed_on_disk_cb, data);

  data->theme_custom = theme_load_from_gsettings (data);
  data->theme_custom->name = g_strdup (CUSTOM_THEME_NAME);
  data->theme_custom->readable_name = g_strdup_printf ("<i>%s</i>", _("Custom"));

  for (l = theme_list; l; l = l->next) {
    MateThemeMetaInfo *info = l->data;

    gtk_list_store_insert_with_values (theme_store, NULL, 0,
        COL_LABEL, info->readable_name,
        COL_NAME, info->name,
        COL_THUMBNAIL, data->theme_icon,
        -1);

    if (!meta_theme && theme_is_equal (data->theme_custom, info))
      meta_theme = info;
  }

  if (!meta_theme) {
    /* add custom theme */
    meta_theme = data->theme_custom;

    gtk_list_store_insert_with_values (theme_store, NULL, 0,
        COL_LABEL, meta_theme->readable_name,
        COL_NAME, meta_theme->name,
        COL_THUMBNAIL, data->theme_icon,
        -1);

    theme_thumbnail_generate (meta_theme, data);
  }

  theme_list = g_list_sort (theme_list, (GCompareFunc) theme_list_sort_func);

  g_list_foreach (theme_list, (GFunc) theme_thumbnail_generate, data);
  g_list_free (theme_list);

  icon_view = GTK_ICON_VIEW (appearance_capplet_get_widget (data, "theme_list"));

  renderer = gtk_cell_renderer_pixbuf_new ();
  g_object_set (renderer, "xpad", 5, "ypad", 5,
                          "xalign", 0.5, "yalign", 1.0, NULL);
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (icon_view), renderer, FALSE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_view), renderer,
                                  "pixbuf", COL_THUMBNAIL, NULL);

  renderer = gtk_cell_renderer_text_new ();
  g_object_set (renderer, "alignment", PANGO_ALIGN_CENTER,
                          "wrap-mode", PANGO_WRAP_WORD_CHAR,
                          "wrap-width", gtk_icon_view_get_item_width (icon_view),
                          "width", gtk_icon_view_get_item_width (icon_view),
                          "xalign", 0.5, "yalign", 0.0, NULL);

  gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (icon_view), renderer, FALSE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_view), renderer,
                                  "markup", COL_LABEL, NULL);

  sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (theme_store));
  gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (sort_model), COL_LABEL, theme_store_sort_func, NULL, NULL);
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model), COL_LABEL, GTK_SORT_ASCENDING);
  gtk_icon_view_set_model (icon_view, GTK_TREE_MODEL (sort_model));

  g_signal_connect (icon_view, "selection-changed", (GCallback) theme_selection_changed_cb, data);
  g_signal_connect_after (icon_view, "realize", (GCallback) theme_select_name, meta_theme->name);

  w = appearance_capplet_get_widget (data, "theme_install");
  gtk_button_set_image (GTK_BUTTON (w),
                        gtk_image_new_from_icon_name ("document-open", GTK_ICON_SIZE_BUTTON));
  g_signal_connect (w, "clicked", (GCallback) theme_install_cb, data);

  w = appearance_capplet_get_widget (data, "theme_save");
  gtk_button_set_image (GTK_BUTTON (w),
                        gtk_image_new_from_icon_name ("document-save-as", GTK_ICON_SIZE_BUTTON));
  g_signal_connect (w, "clicked", (GCallback) theme_save_cb, data);

  w = appearance_capplet_get_widget (data, "theme_custom");
  gtk_button_set_image (GTK_BUTTON (w),
                        gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_BUTTON));
  g_signal_connect (w, "clicked", (GCallback) theme_custom_cb, data);

  del_button = appearance_capplet_get_widget (data, "theme_delete");
  g_signal_connect (del_button, "clicked", (GCallback) theme_delete_cb, data);

  w = appearance_capplet_get_widget (data, "theme_vbox");
  gtk_drag_dest_set (w, GTK_DEST_DEFAULT_ALL,
		     drop_types, G_N_ELEMENTS (drop_types),
		     GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE);
  g_signal_connect (w, "drag-data-received", (GCallback) theme_drag_data_received_cb, data);
  if (is_locked_down ())
    gtk_widget_set_sensitive (w, FALSE);

  w = appearance_capplet_get_widget (data, "more_themes_linkbutton");
  url = g_settings_get_string (data->settings, MORE_THEMES_URL_KEY);
  if (url != NULL && url[0] != '\0') {
    gtk_link_button_set_uri (GTK_LINK_BUTTON (w), url);
    gtk_widget_show (w);
  } else {
    gtk_widget_hide (w);
  }
  g_free (url);

  /* listen to gsettings changes, too */
  g_signal_connect (data->marco_settings, "changed::" MARCO_THEME_KEY, G_CALLBACK (theme_gsettings_changed), data);
  g_signal_connect (data->mouse_settings, "changed::" CURSOR_THEME_KEY, G_CALLBACK (theme_gsettings_changed), data);
  g_signal_connect (data->mouse_settings, "changed::" CURSOR_SIZE_KEY, G_CALLBACK (theme_gsettings_changed), data);
  g_signal_connect (data->wp_settings, "changed::" WP_FILE_KEY, G_CALLBACK (background_or_font_changed), data);
  g_signal_connect (data->interface_settings, "changed::" GTK_FONT_KEY, G_CALLBACK (background_or_font_changed), data);
  g_signal_connect (data->interface_settings, "changed::" DOCUMENT_FONT_KEY, G_CALLBACK (background_or_font_changed), data);

  if (data->caja_settings)
    g_signal_connect (data->caja_settings, "changed::" DESKTOP_FONT_KEY, G_CALLBACK (background_or_font_changed), data);

  g_signal_connect (data->marco_settings, "changed::" WINDOW_TITLE_FONT_KEY, G_CALLBACK (background_or_font_changed), data);
  g_signal_connect (data->interface_settings, "changed::" MONOSPACE_FONT_KEY, G_CALLBACK (background_or_font_changed), data);

  settings = gtk_settings_get_default ();
  g_signal_connect (settings, "notify::gtk-color-scheme", (GCallback) theme_setting_changed_cb, data);
  g_signal_connect (settings, "notify::gtk-theme-name", (GCallback) theme_setting_changed_cb, data);
  g_signal_connect (settings, "notify::gtk-icon-theme-name", (GCallback) theme_setting_changed_cb, data);

  /* monitor individual font choice buttons, so
     "revert font" option (if any) can be cleared */
  w = appearance_capplet_get_widget (data, "application_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
  w = appearance_capplet_get_widget (data, "document_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
  w = appearance_capplet_get_widget (data, "desktop_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
  w = appearance_capplet_get_widget (data, "window_title_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
  w = appearance_capplet_get_widget (data, "monospace_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
}
Esempio n. 3
0
static void
setup_options (void)
{
	MatePanelAppletsManager *manager;
	GList               *applet_list, *l;
	int                  i;
	int                  j;
	char                *prefs_path = NULL;
	char                *unique_key = NULL;
	gboolean             unique_key_found = FALSE;
	gchar              **dconf_paths;
	GtkListStore        *model;
	GtkTreeIter          iter;
	GtkCellRenderer     *renderer;

	model = gtk_list_store_new (NUMBER_COLUMNS,
				    G_TYPE_STRING,
				    G_TYPE_STRING);

	gtk_combo_box_set_model (GTK_COMBO_BOX (applet_combo),
				 GTK_TREE_MODEL (model));

	manager = g_object_new (PANEL_TYPE_APPLETS_MANAGER_DBUS, NULL);
	applet_list = MATE_PANEL_APPLETS_MANAGER_GET_CLASS (manager)->get_applets (manager);
	for (l = applet_list, i = 1; l; l = g_list_next (l), i++) {
		MatePanelAppletInfo *info = (MatePanelAppletInfo *)l->data;

		gtk_list_store_append (model, &iter);
		gtk_list_store_set (model, &iter,
				    COLUMN_TEXT, g_strdup (mate_panel_applet_info_get_name (info)),
				    COLUMN_ITEM, g_strdup (mate_panel_applet_info_get_iid (info)),
				    -1);
	}
	g_list_free (applet_list);
	g_object_unref (manager);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (applet_combo),
				    renderer, TRUE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (applet_combo),
					renderer, "text", COLUMN_TEXT, NULL);

	gtk_combo_box_set_active (GTK_COMBO_BOX (applet_combo), 0);

	setup_combo (size_combo, size_items, "Size",
		     G_N_ELEMENTS (size_items));
	setup_combo (orient_combo, orient_items, "Orientation",
		     G_N_ELEMENTS (orient_items));

	for (i = 0; !unique_key_found; i++)
	{
		unique_key = g_strdup_printf ("mate-panel-test-applet-%d", i);
		unique_key_found = TRUE;
		dconf_paths = panel_dconf_list_subdirs ("/tmp/", TRUE);
		for (j = 0; dconf_paths[j] != NULL; j++)
		{
			if (g_strcmp0(unique_key, dconf_paths[j]) == 0) {
				unique_key_found = FALSE;
				break;
			}
		}
		if (dconf_paths)
			g_strfreev (dconf_paths);
	}
	
	prefs_path = g_strdup_printf ("/tmp/%s/", unique_key);
	if (unique_key)
		g_free (unique_key);
	gtk_entry_set_text (GTK_ENTRY (prefs_path_entry), prefs_path);
	g_free (prefs_path);
}
Esempio n. 4
0
static GtkWidget *create_window(void)
{
    GtkWidget *startwin;
    GtkWidget *hlayout;
    GtkWidget *banner;
    GtkWidget *vlayout;
    GtkWidget *tabs;
    GtkWidget *configvlayout;
    GtkWidget *configlayout;
    GtkWidget *vmode3dlabel;
    GtkWidget *vmode3dcombo;
    GtkWidget *fullscreencheck;
    GtkWidget *alwaysshowcheck;
    GtkWidget *configtab;
    GtkWidget *messagesscroll;
    GtkWidget *messagestext;
    GtkWidget *messagestab;
    GtkWidget *buttons;
    GtkWidget *cancelbutton;
    GtkWidget *cancelbuttonalign;
    GtkWidget *cancelbuttonlayout;
    GtkWidget *cancelbuttonicon;
    GtkWidget *cancelbuttonlabel;
    GtkWidget *startbutton;
    GtkWidget *startbuttonalign;
    GtkWidget *startbuttonlayout;
    GtkWidget *startbuttonicon;
    GtkWidget *startbuttonlabel;
    GtkAccelGroup *accel_group;

    accel_group = gtk_accel_group_new();

    // Basic window
    startwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(startwin), apptitle);     // NOTE: use global app title
    gtk_window_set_position(GTK_WINDOW(startwin), GTK_WIN_POS_CENTER);
    gtk_window_set_resizable(GTK_WINDOW(startwin), FALSE);
    gtk_window_set_type_hint(GTK_WINDOW(startwin), GDK_WINDOW_TYPE_HINT_DIALOG);

    // Horizontal layout of banner and controls
    hlayout = gtk_hbox_new(FALSE, 0);
    gtk_widget_show(hlayout);
    gtk_container_add(GTK_CONTAINER(startwin), hlayout);

    // Banner
    {
        GdkPixbuf *pixbuf = load_banner();
        banner = gtk_image_new_from_pixbuf(pixbuf);
        g_object_unref((gpointer)pixbuf);
    }
    gtk_widget_show(banner);
    gtk_box_pack_start(GTK_BOX(hlayout), banner, FALSE, FALSE, 0);
    gtk_misc_set_alignment(GTK_MISC(banner), 0.5, 0);

    // Vertical layout of tab control and start+cancel buttons
    vlayout = gtk_vbox_new(FALSE, 0);
    gtk_widget_show(vlayout);
    gtk_box_pack_start(GTK_BOX(hlayout), vlayout, TRUE, TRUE, 0);

    // Tab control
    tabs = gtk_notebook_new();
    gtk_widget_show(tabs);
    gtk_box_pack_start(GTK_BOX(vlayout), tabs, TRUE, TRUE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(tabs), 4);

    // Vertical layout of config page main body
    configvlayout = gtk_vbox_new(FALSE, 0);
    gtk_widget_show(configvlayout);
    gtk_container_add(GTK_CONTAINER(tabs), configvlayout);

    // Fixed-position layout of config page controls
    configlayout = gtk_fixed_new();
    gtk_widget_show(configlayout);
    gtk_box_pack_start(GTK_BOX(configvlayout), configlayout, TRUE, TRUE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(configlayout), 6);

    // 3D video mode label
    vmode3dlabel = gtk_label_new_with_mnemonic("_Video mode:");
    gtk_widget_show(vmode3dlabel);
    gtk_fixed_put(GTK_FIXED(configlayout), vmode3dlabel, 0, 0);
    gtk_widget_set_size_request(vmode3dlabel, 88, 29);
    gtk_misc_set_alignment(GTK_MISC(vmode3dlabel), 0, 0.5);

    // 3D video mode combo
    {
        GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
        GtkCellRenderer *cell;

        vmode3dcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
        g_object_unref(G_OBJECT(list));

        cell = gtk_cell_renderer_text_new();
        gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(vmode3dcombo), cell, FALSE);
        gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(vmode3dcombo), cell, "text", 0, NULL);
    }
    gtk_widget_show(vmode3dcombo);
    gtk_fixed_put(GTK_FIXED(configlayout), vmode3dcombo, 88, 0);
    gtk_widget_set_size_request(vmode3dcombo, 150, 29);
    gtk_widget_add_accelerator(vmode3dcombo, "grab_focus", accel_group,
                               GDK_V, GDK_MOD1_MASK,
                               GTK_ACCEL_VISIBLE);

    // Fullscreen checkbox
    fullscreencheck = gtk_check_button_new_with_mnemonic("_Fullscreen");
    gtk_widget_show(fullscreencheck);
    gtk_fixed_put(GTK_FIXED(configlayout), fullscreencheck, 248, 0);
    gtk_widget_set_size_request(fullscreencheck, 85, 29);
    gtk_widget_add_accelerator(fullscreencheck, "grab_focus", accel_group,
                               GDK_F, GDK_MOD1_MASK,
                               GTK_ACCEL_VISIBLE);

    // Always show config checkbox
    alwaysshowcheck = gtk_check_button_new_with_mnemonic("_Always show configuration on start");
    gtk_widget_show(alwaysshowcheck);
    gtk_box_pack_start(GTK_BOX(configvlayout), alwaysshowcheck, FALSE, FALSE, 0);
    gtk_widget_add_accelerator(alwaysshowcheck, "grab_focus", accel_group,
                               GDK_A, GDK_MOD1_MASK,
                               GTK_ACCEL_VISIBLE);

    // Configuration tab
    configtab = gtk_label_new("Configuration");
    gtk_widget_show(configtab);
    gtk_notebook_set_tab_label(GTK_NOTEBOOK(tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(tabs), 0), configtab);

    // Messages scrollable area
    messagesscroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_widget_show(messagesscroll);
    gtk_container_add(GTK_CONTAINER(tabs), messagesscroll);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(messagesscroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);

    // Messages text area
    messagestext = gtk_text_view_new();
    gtk_widget_show(messagestext);
    gtk_container_add(GTK_CONTAINER(messagesscroll), messagestext);
    gtk_text_view_set_editable(GTK_TEXT_VIEW(messagestext), FALSE);
    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(messagestext), GTK_WRAP_WORD);
    gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(messagestext), FALSE);
    gtk_text_view_set_left_margin(GTK_TEXT_VIEW(messagestext), 2);
    gtk_text_view_set_right_margin(GTK_TEXT_VIEW(messagestext), 2);

    // Messages tab
    messagestab = gtk_label_new("Messages");
    gtk_widget_show(messagestab);
    gtk_notebook_set_tab_label(GTK_NOTEBOOK(tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(tabs), 1), messagestab);

    // Dialogue box buttons layout
    buttons = gtk_hbutton_box_new();
    gtk_widget_show(buttons);
    gtk_box_pack_start(GTK_BOX(vlayout), buttons, FALSE, TRUE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(buttons), 3);
    gtk_button_box_set_layout(GTK_BUTTON_BOX(buttons), GTK_BUTTONBOX_END);

    // Cancel button
    cancelbutton = gtk_button_new();
    gtk_widget_show(cancelbutton);
    gtk_container_add(GTK_CONTAINER(buttons), cancelbutton);
    GTK_WIDGET_SET_FLAGS(cancelbutton, GTK_CAN_DEFAULT);
    gtk_widget_add_accelerator(cancelbutton, "grab_focus", accel_group,
                               GDK_C, GDK_MOD1_MASK,
                               GTK_ACCEL_VISIBLE);
    gtk_widget_add_accelerator(cancelbutton, "clicked", accel_group,
                               GDK_Escape, 0,
                               GTK_ACCEL_VISIBLE);

    cancelbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_widget_show(cancelbuttonalign);
    gtk_container_add(GTK_CONTAINER(cancelbutton), cancelbuttonalign);

    cancelbuttonlayout = gtk_hbox_new(FALSE, 2);
    gtk_widget_show(cancelbuttonlayout);
    gtk_container_add(GTK_CONTAINER(cancelbuttonalign), cancelbuttonlayout);

    cancelbuttonicon = gtk_image_new_from_stock("gtk-cancel", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show(cancelbuttonicon);
    gtk_box_pack_start(GTK_BOX(cancelbuttonlayout), cancelbuttonicon, FALSE, FALSE, 0);

    cancelbuttonlabel = gtk_label_new_with_mnemonic("_Cancel");
    gtk_widget_show(cancelbuttonlabel);
    gtk_box_pack_start(GTK_BOX(cancelbuttonlayout), cancelbuttonlabel, FALSE, FALSE, 0);

    // Start button
    startbutton = gtk_button_new();
    gtk_widget_show(startbutton);
    gtk_container_add(GTK_CONTAINER(buttons), startbutton);
    GTK_WIDGET_SET_FLAGS(startbutton, GTK_CAN_DEFAULT);
    gtk_widget_add_accelerator(startbutton, "grab_focus", accel_group,
                               GDK_S, GDK_MOD1_MASK,
                               GTK_ACCEL_VISIBLE);
    gtk_widget_add_accelerator(startbutton, "clicked", accel_group,
                               GDK_Return, 0,
                               GTK_ACCEL_VISIBLE);

    startbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0);
    gtk_widget_show(startbuttonalign);
    gtk_container_add(GTK_CONTAINER(startbutton), startbuttonalign);

    startbuttonlayout = gtk_hbox_new(FALSE, 2);
    gtk_widget_show(startbuttonlayout);
    gtk_container_add(GTK_CONTAINER(startbuttonalign), startbuttonlayout);

    startbuttonicon = gtk_image_new_from_stock("gtk-execute", GTK_ICON_SIZE_BUTTON);
    gtk_widget_show(startbuttonicon);
    gtk_box_pack_start(GTK_BOX(startbuttonlayout), startbuttonicon, FALSE, FALSE, 0);

    startbuttonlabel = gtk_label_new_with_mnemonic("_Start");
    gtk_widget_show(startbuttonlabel);
    gtk_box_pack_start(GTK_BOX(startbuttonlayout), startbuttonlabel, FALSE, FALSE, 0);

    // Wire up the signals
    g_signal_connect((gpointer) startwin, "delete_event",
                     G_CALLBACK(on_startwin_delete_event),
                     NULL);
    g_signal_connect((gpointer) vmode3dcombo, "changed",
                     G_CALLBACK(on_vmode3dcombo_changed),
                     NULL);
    g_signal_connect((gpointer) fullscreencheck, "toggled",
                     G_CALLBACK(on_fullscreencheck_toggled),
                     NULL);
    g_signal_connect((gpointer) alwaysshowcheck, "toggled",
                     G_CALLBACK(on_alwaysshowcheck_toggled),
                     NULL);
    g_signal_connect((gpointer) cancelbutton, "clicked",
                     G_CALLBACK(on_cancelbutton_clicked),
                     NULL);
    g_signal_connect((gpointer) startbutton, "clicked",
                     G_CALLBACK(on_startbutton_clicked),
                     NULL);

    // Associate labels with their controls
    gtk_label_set_mnemonic_widget(GTK_LABEL(vmode3dlabel), vmode3dcombo);

    /* Store pointers to all widgets, for use by lookup_widget(). */
    GLADE_HOOKUP_OBJECT_NO_REF(startwin, startwin, "startwin");
    GLADE_HOOKUP_OBJECT(startwin, hlayout, "hlayout");
    GLADE_HOOKUP_OBJECT(startwin, banner, "banner");
    GLADE_HOOKUP_OBJECT(startwin, vlayout, "vlayout");
    GLADE_HOOKUP_OBJECT(startwin, tabs, "tabs");
    GLADE_HOOKUP_OBJECT(startwin, configvlayout, "configvlayout");
    GLADE_HOOKUP_OBJECT(startwin, configlayout, "configlayout");
    GLADE_HOOKUP_OBJECT(startwin, vmode3dlabel, "vmode3dlabel");
    GLADE_HOOKUP_OBJECT(startwin, vmode3dcombo, "vmode3dcombo");
    GLADE_HOOKUP_OBJECT(startwin, fullscreencheck, "fullscreencheck");
    GLADE_HOOKUP_OBJECT(startwin, alwaysshowcheck, "alwaysshowcheck");
    GLADE_HOOKUP_OBJECT(startwin, configtab, "configtab");
    GLADE_HOOKUP_OBJECT(startwin, messagesscroll, "messagesscroll");
    GLADE_HOOKUP_OBJECT(startwin, messagestext, "messagestext");
    GLADE_HOOKUP_OBJECT(startwin, messagestab, "messagestab");
    GLADE_HOOKUP_OBJECT(startwin, buttons, "buttons");
    GLADE_HOOKUP_OBJECT(startwin, cancelbutton, "cancelbutton");
    GLADE_HOOKUP_OBJECT(startwin, cancelbuttonalign, "cancelbuttonalign");
    GLADE_HOOKUP_OBJECT(startwin, cancelbuttonlayout, "cancelbuttonlayout");
    GLADE_HOOKUP_OBJECT(startwin, cancelbuttonicon, "cancelbuttonicon");
    GLADE_HOOKUP_OBJECT(startwin, cancelbuttonlabel, "cancelbuttonlabel");
    GLADE_HOOKUP_OBJECT(startwin, startbutton, "startbutton");
    GLADE_HOOKUP_OBJECT(startwin, startbuttonalign, "startbuttonalign");
    GLADE_HOOKUP_OBJECT(startwin, startbuttonlayout, "startbuttonlayout");
    GLADE_HOOKUP_OBJECT(startwin, startbuttonicon, "startbuttonicon");
    GLADE_HOOKUP_OBJECT(startwin, startbuttonlabel, "startbuttonlabel");

    gtk_window_add_accel_group(GTK_WINDOW(startwin), accel_group);

    return startwin;
}
Esempio n. 5
0
static void
dlg_photo_importer (GthBrowser            *browser,
		    GFile                 *source,
		    DlgImporterSourceType  selector_type)
{
	DialogData       *data;
	GtkCellRenderer  *renderer;
	GthFileDataSort  *sort_type;
	GList            *tests, *scan;
	char             *general_filter;
	int               i, active_filter;
	int               i_general;

	if (gth_browser_get_dialog (browser, "photo_importer") != NULL) {
		gtk_window_present (GTK_WINDOW (gth_browser_get_dialog (browser, "photo_importer")));
		return;
	}

	data = g_new0 (DialogData, 1);
	data->browser = browser;
	data->builder = gtk_builder_new_from_resource ("/org/gnome/gThumb/photo_importer/data/ui/photo-importer.ui");
	data->settings = g_settings_new (GTHUMB_PHOTO_IMPORTER_SCHEMA);
	data->selector_type = selector_type;
	data->source = _g_object_ref (source);
	data->cancellable = g_cancellable_new ();
	data->vfs_source = g_object_new (GTH_TYPE_FILE_SOURCE_VFS, NULL);
	gth_file_source_monitor_entry_points (GTH_FILE_SOURCE (data->vfs_source));

	/* Get the widgets. */

	data->dialog = _gtk_builder_get_widget (data->builder, "photo_importer_dialog");
	_gtk_window_resize_to_fit_screen_height (data->dialog, 580);
	gth_browser_set_dialog (browser, "photo_importer", data->dialog);
	g_object_set_data (G_OBJECT (data->dialog), "dialog_data", data);

	if (data->selector_type == DLG_IMPORTER_SOURCE_TYPE_DEVICE) {
		gtk_window_set_title (GTK_WINDOW (data->dialog), _("Import from Removable Device"));

		data->device_list_store = gtk_list_store_new (SOURCE_LIST_COLUMNS, G_TYPE_OBJECT, G_TYPE_ICON, G_TYPE_STRING);
		data->device_chooser = gtk_combo_box_new_with_model (GTK_TREE_MODEL (data->device_list_store));
		gtk_widget_show (data->device_chooser);
		gtk_box_pack_start (GTK_BOX (GET_WIDGET ("source_box")), data->device_chooser, TRUE, TRUE, 0);
		gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("source_label")), data->device_chooser);

		renderer = gtk_cell_renderer_pixbuf_new ();
		gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (data->device_chooser), renderer, FALSE);
		gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (data->device_chooser),
						renderer,
						"gicon", SOURCE_LIST_COLUMN_ICON,
						NULL);

		renderer = gtk_cell_renderer_text_new ();
		gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (data->device_chooser), renderer, TRUE);
		gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (data->device_chooser),
						renderer,
						"text", SOURCE_LIST_COLUMN_NAME,
						NULL);

		g_object_unref (data->device_list_store);
	}
	else {
		if (data->source == NULL) {
			if (GTH_IS_FILE_SOURCE_VFS (gth_browser_get_location_source (browser)))
				data->source = _g_object_ref (gth_browser_get_location (browser));
			if (data->source == NULL)
				data->source = g_file_new_for_uri (get_home_uri ());
		}

		gtk_window_set_title (GTK_WINDOW (data->dialog), _("Import from Folder"));

		data->folder_chooser = gtk_file_chooser_button_new (_("Choose a folder"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
		gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("source_label")), data->folder_chooser);
		gtk_file_chooser_set_file (GTK_FILE_CHOOSER (data->folder_chooser), data->source, NULL);
		gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (data->folder_chooser), FALSE);
		gtk_widget_show (data->folder_chooser);
		gtk_box_pack_start (GTK_BOX (GET_WIDGET ("source_box")), data->folder_chooser, TRUE, TRUE, 0);
	}

	data->file_list = gth_file_list_new (gth_grid_view_new (), GTH_FILE_LIST_MODE_NORMAL, FALSE);
	sort_type = gth_main_get_sort_type ("file::mtime");
	gth_file_list_set_sort_func (GTH_FILE_LIST (data->file_list), sort_type->cmp_func, FALSE);
	gth_file_list_enable_thumbs (GTH_FILE_LIST (data->file_list), TRUE);
	gth_file_list_set_ignore_hidden (GTH_FILE_LIST (data->file_list), TRUE);
	gth_file_list_set_thumb_size (GTH_FILE_LIST (data->file_list), 128);
	gth_file_list_set_caption (GTH_FILE_LIST (data->file_list), "standard::display-name,gth::file::display-size");

	gtk_widget_show (data->file_list);
	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("filelist_box")), data->file_list, TRUE, TRUE, 0);

	tests = gth_main_get_registered_objects_id (GTH_TYPE_TEST);
	general_filter = "file::type::is_media"; /* default value */
	active_filter = 0;

	data->filter_combobox = gtk_combo_box_text_new ();
	for (i = 0, i_general = -1, scan = tests; scan; scan = scan->next, i++) {
		const char *registered_test_id = scan->data;
		GthTest    *test;

		if (strncmp (registered_test_id, "file::type::", 12) != 0)
			continue;

		i_general += 1;
		test = gth_main_get_registered_object (GTH_TYPE_TEST, registered_test_id);
		if (strcmp (registered_test_id, general_filter) == 0) {
			active_filter = i_general;
			gth_file_list_set_filter (GTH_FILE_LIST (data->file_list), test);
		}

		data->general_tests = g_list_prepend (data->general_tests, g_strdup (gth_test_get_id (test)));
		gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (data->filter_combobox),
						gth_test_get_display_name (test));
		g_object_unref (test);
	}
	data->general_tests = g_list_reverse (data->general_tests);

	gtk_combo_box_set_active (GTK_COMBO_BOX (data->filter_combobox), active_filter);
	gtk_widget_show (data->filter_combobox);
	gtk_container_add (GTK_CONTAINER (GET_WIDGET ("filter_box")), data->filter_combobox);

	gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("filter_label")), data->filter_combobox);
	gtk_label_set_use_underline (GTK_LABEL (GET_WIDGET ("filter_label")), TRUE);

	_g_string_list_free (tests);

	data->tags_entry = gth_tags_entry_new (GTH_TAGS_ENTRY_MODE_POPUP);
	gtk_widget_show (data->tags_entry);
	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("tags_entry_box")), data->tags_entry, TRUE, TRUE, 0);
	gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("tags_label")), data->tags_entry);

	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("delete_checkbutton")),
				      g_settings_get_boolean (data->settings, PREF_PHOTO_IMPORTER_DELETE_FROM_DEVICE));

	data->preferences_dialog = gth_import_preferences_dialog_new ();
	gtk_window_set_transient_for (GTK_WINDOW (data->preferences_dialog), GTK_WINDOW (data->dialog));

	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("destination_button_box")),
			    gth_import_destination_button_new (GTH_IMPORT_PREFERENCES_DIALOG (data->preferences_dialog)),
			    TRUE,
			    TRUE,
			    0);
	gtk_widget_show_all (GET_WIDGET ("destination_button_box"));

	/* Set the signals handlers. */

	g_signal_connect (G_OBJECT (data->dialog),
			  "delete-event",
			  G_CALLBACK (dialog_delete_event_cb),
			  data);
	g_signal_connect (GET_WIDGET ("ok_button"),
			  "clicked",
			  G_CALLBACK (ok_clicked_cb),
			  data);
	g_signal_connect (GET_WIDGET ("cancel_button"),
			  "clicked",
			  G_CALLBACK (close_dialog),
			  data);
        if (data->selector_type == DLG_IMPORTER_SOURCE_TYPE_DEVICE)
		g_signal_connect (data->device_chooser,
				  "changed",
				  G_CALLBACK (device_chooser_changed_cb),
				  data);
        else
		g_signal_connect (data->folder_chooser,
				  "selection-changed",
				  G_CALLBACK (folder_chooser_file_set_cb),
				  data);
	g_signal_connect (data->filter_combobox,
			  "changed",
			  G_CALLBACK (filter_combobox_changed_cb),
			  data);
	g_signal_connect (gth_file_view_get_model (GTH_FILE_VIEW (gth_file_list_get_view (GTH_FILE_LIST (data->file_list)))),
			  "visibility_changed",
			  G_CALLBACK (file_store_changed_cb),
			  data);
	g_signal_connect (gth_file_list_get_view (GTH_FILE_LIST (data->file_list)),
			  "file-selection-changed",
			  G_CALLBACK (file_view_selection_changed_cb),
			  data);
	data->entry_points_changed_id = g_signal_connect (gth_main_get_default_monitor (),
							  "entry-points-changed",
							  G_CALLBACK (entry_points_changed_cb),
							  data);
	g_signal_connect_after (GET_WIDGET ("event_entry"),
				"changed",
				G_CALLBACK (event_entry_changed_cb),
				data);

	/* Run dialog. */

	gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (browser));
	gtk_window_set_modal (GTK_WINDOW (data->dialog), FALSE);
	gtk_widget_show (data->dialog);

	gth_import_preferences_dialog_set_event (GTH_IMPORT_PREFERENCES_DIALOG (data->preferences_dialog),
						 gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("event_entry"))));

	if (data->selector_type == DLG_IMPORTER_SOURCE_TYPE_DEVICE)
		update_device_source_list (data);
	else
		load_file_list (data);
}
Esempio n. 6
0
static void
mud_connections_show_properties(MudConnections *conn, gchar *mud)
{
    GladeXML *glade;
    GConfClient *client;
    GtkTextBuffer *buffer;
    gchar *key, *buf, *name_strip, *char_strip;
    gint port;
    gchar **mud_tuple;

    glade =
	glade_xml_new(GLADEDIR "/muds.glade", "mudviewproperties", NULL);

    conn->priv->properties_window =
	glade_xml_get_widget(glade, "mudviewproperties");
    conn->priv->name_entry = glade_xml_get_widget(glade, "name_entry");
    conn->priv->host_entry = glade_xml_get_widget(glade, "host_entry");
    conn->priv->port_entry = glade_xml_get_widget(glade, "port_entry");
    conn->priv->icon_button = glade_xml_get_widget(glade, "icon_button");
    conn->priv->icon_image = glade_xml_get_widget(glade, "icon_image");
    conn->priv->profile_combo =
	glade_xml_get_widget(glade, "profile_combo");
    conn->priv->character_name_entry =
	glade_xml_get_widget(glade, "character_name_entry");
    conn->priv->logon_textview =
	glade_xml_get_widget(glade, "character_logon_textview");

    if(conn->priv->icon_current)
	g_free(conn->priv->icon_current);
    conn->priv->icon_current = NULL;

    mud_connections_property_populate_profiles(conn);
    gtk_combo_box_set_model(
	GTK_COMBO_BOX(conn->priv->profile_combo),
	conn->priv->profile_model);
    g_object_unref(conn->priv->profile_model);

    conn->priv->profile_combo_renderer = gtk_cell_renderer_text_new();
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(conn->priv->profile_combo),
			       conn->priv->profile_combo_renderer, TRUE);
    gtk_cell_layout_set_attributes(
	GTK_CELL_LAYOUT(conn->priv->profile_combo),
	conn->priv->profile_combo_renderer, "text", 0, NULL);

    g_signal_connect(conn->priv->properties_window, "delete-event",
		     G_CALLBACK(mud_connections_property_delete_cb), conn);
    g_signal_connect(glade_xml_get_widget(glade, "cancel_button"),
		     "clicked",
		     G_CALLBACK(mud_connections_property_cancel_cb),
		     conn);
    g_signal_connect(glade_xml_get_widget(glade, "save_button"),
		     "clicked",
		     G_CALLBACK(mud_connections_property_save_cb),
		     conn);
    g_signal_connect(glade_xml_get_widget(glade, "icon_button"),
		     "clicked",
		     G_CALLBACK(mud_connections_property_icon_cb),
		     conn);
    g_signal_connect(glade_xml_get_widget(glade, "name_entry"),
		     "key-press-event",
		     G_CALLBACK(mud_connections_property_changed_cb),
		     conn);
    g_signal_connect(glade_xml_get_widget(glade, "host_entry"),
		     "key-press-event",
		     G_CALLBACK(mud_connections_property_changed_cb),
		     conn);
    g_signal_connect(glade_xml_get_widget(glade, "port_entry"),
		     "key-press-event",
		     G_CALLBACK(mud_connections_property_changed_cb),
		     conn);
    g_signal_connect(glade_xml_get_widget(glade, "character_name_entry"),
		     "key-press-event",
		     G_CALLBACK(mud_connections_property_changed_cb),
		     conn);
    g_signal_connect(
	glade_xml_get_widget(glade, "character_logon_textview"),
	"key-press-event",
	G_CALLBACK(mud_connections_property_changed_cb),
	conn);
    g_signal_connect(glade_xml_get_widget(glade, "profile_combo"),
		     "changed",
		     G_CALLBACK(mud_connections_property_combo_changed_cb),
		     conn);

    g_object_unref(glade);

    if(conn->priv->original_name != NULL)
	g_free(conn->priv->original_name);
    conn->priv->original_name = NULL;

    if(conn->priv->original_char_name != NULL)
	g_free(conn->priv->original_char_name);
    conn->priv->original_char_name = NULL;

    if(mud != NULL)
    {
	gint len;
	mud_tuple = g_strsplit(mud, "\n", -1);
	g_free(mud);
	len = g_strv_length(mud_tuple);

	switch(len)
	{
	case 1:
	    conn->priv->original_name = g_strdup(mud_tuple[0]);
	    break;

	case 2:
	    conn->priv->original_char_name = g_strdup(mud_tuple[0]);
	    conn->priv->original_name = g_strdup(mud_tuple[1]);
	    break;
	}

	g_strfreev(mud_tuple);
    } else
	return;

    name_strip = gconf_escape_key(conn->priv->original_name, -1);

    gtk_entry_set_text(
	GTK_ENTRY(conn->priv->name_entry), conn->priv->original_name);

    if(conn->priv->original_char_name)
	gtk_entry_set_text(GTK_ENTRY(conn->priv->character_name_entry),
			   conn->priv->original_char_name);

    client = gconf_client_get_default();

    key = g_strdup_printf("/apps/gnome-mud/muds/%s/host", name_strip);
    buf = gconf_client_get_string(client, key, NULL);
    g_free(key);

    if(buf)
    {
	gtk_entry_set_text(GTK_ENTRY(conn->priv->host_entry), buf);
	g_free(buf);
    }

    key = g_strdup_printf("/apps/gnome-mud/muds/%s/port", name_strip);
    port = gconf_client_get_int(client, key, NULL);
    g_free(key);

    if(port != 0)
	gtk_spin_button_set_value(
	    GTK_SPIN_BUTTON(conn->priv->port_entry), port);

    key = g_strdup_printf("/apps/gnome-mud/muds/%s/profile", name_strip);
    buf = gconf_client_get_string(client, key, NULL);
    g_free(key);

    if(buf)
    {
	mud_connections_property_combo_get_index(conn, buf);
	g_free(buf);
    }

    key = g_strdup_printf("/apps/gnome-mud/muds/%s/icon", name_strip);
    buf = gconf_client_get_string(client, key, NULL);
    g_free(key);

    if(buf && strcmp(buf, "gnome-mud") != 0)
    {
	GdkPixbuf *icon;

	conn->priv->icon_current = g_strdup(buf);
	g_free(buf);

	icon = gdk_pixbuf_new_from_file_at_size(
	    conn->priv->icon_current, 48, 48, NULL);
	gtk_image_set_from_pixbuf(GTK_IMAGE(conn->priv->icon_image),
				  icon);

	g_object_unref(icon);
    }
    else
	conn->priv->icon_current = g_strdup("gnome-mud");

    if(conn->priv->original_char_name != NULL)
    {
	char_strip = gconf_escape_key(conn->priv->original_char_name, -1);
		
	key = g_strdup_printf("/apps/gnome-mud/muds/%s/characters/%s/logon",
			      name_strip, char_strip);
	buf = gconf_client_get_string(client, key, NULL);
	g_free(key);

	if(buf)
	{
	    buffer =
		gtk_text_view_get_buffer(
		    GTK_TEXT_VIEW(conn->priv->logon_textview));
	    gtk_text_buffer_set_text(buffer, buf, strlen(buf));
	    g_free(buf);
	}

	g_free(char_strip);
    }

    g_free(name_strip);

    g_object_unref(client);

    conn->priv->changed = FALSE;
}
Esempio n. 7
0
CExpressDlg::CExpressDlg(GtkWindow *pParent):m_pParent(pParent), m_ConvertBtn(NULL), m_ChannelCombo(NULL), 
	m_TimeCorrBtn(NULL), m_SecondsEdit(NULL), m_SecondsBtn(NULL), m_BiasCorrBtn(NULL), 
	m_BiasFrameEdit(NULL), m_BiasFrameBtn(NULL), m_DarkCorrBtn(NULL), m_DarkFrameEdit(NULL), 
	m_DarkFrameBtn(NULL), m_FlatCorrBtn(NULL), m_FlatFrameEdit(NULL), m_FlatFrameBtn(NULL), 
	m_PhotometryBtn(NULL), m_MatchingBtn(NULL), m_RefBtn(NULL), m_RefFrameCombo(NULL), 
	m_RefFrameBtn(NULL), m_CatBtn(NULL), m_CatFrameEdit(NULL), m_CatFrameBtn(NULL), m_TimeCorr(0), 
	m_Updating(false), m_Matching(false)
{
	int row = 0;
	tProjectType type = g_Project->ProjectType();
	GtkWidget *table;
	GSList *group;
	GtkCellRenderer *renderer;
	GtkTreeIter iter;

	memset(&m_Params, 0, sizeof(tProcParams));

	m_Channels = gtk_list_store_new(2, GTK_TYPE_INT, GTK_TYPE_STRING);
	for (int i=0; RAWChannels[i].caption; i++) {
		if (!RAWChannels[i].debug || type==PROJECT_TEST) {
			gtk_list_store_append(m_Channels, &iter);
			gtk_list_store_set(m_Channels, &iter, 0, RAWChannels[i].type, 1, RAWChannels[i].caption, -1);
		}
	}

	m_Frames = gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING);

	// Dialog with buttons
	m_pDlg = gtk_dialog_new_with_buttons("Express reduction", pParent, 
		(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
		GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, 
		GTK_STOCK_HELP, GTK_RESPONSE_HELP, NULL);
	gtk_dialog_widget_standard_tooltips(GTK_DIALOG(m_pDlg));
	gtk_dialog_set_tooltip_by_response(GTK_DIALOG(m_pDlg), GTK_RESPONSE_ACCEPT, "Start the process");
	g_signal_connect(G_OBJECT(m_pDlg), "response", G_CALLBACK(response_dialog), this);

	// Dialog icon
	gchar *icon = get_icon_file("reduction");
	gtk_window_set_icon(GTK_WINDOW(m_pDlg), gdk_pixbuf_new_from_file(icon, NULL));
	g_free(icon);
	
	// Dialog layout
	table = gtk_table_new(4, 3, FALSE);
	gtk_widget_set_size_request(table, 360, -1);
	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(m_pDlg)->vbox), table, TRUE, TRUE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(table), 8);
	gtk_table_set_row_spacings(GTK_TABLE(table), 4);
	gtk_table_set_col_spacings(GTK_TABLE(table), 4);
	gtk_table_set_row_spacing(GTK_TABLE(table), 2, 12);
	gtk_table_set_col_spacing(GTK_TABLE(table), 0, 16);

	// All frames / selected frames
	GtkWidget *label = gtk_label_new(NULL);
	gtk_label_set_markup(GTK_LABEL(label), "<b>Process</b>");
	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 3, row, row+1);
	m_AllBtn = gtk_radio_button_new_with_label(NULL, "all files in current project");
	gtk_widget_set_tooltip_text(m_AllBtn, "Process all frames in the current project");
	g_signal_connect(G_OBJECT(m_AllBtn), "toggled", G_CALLBACK(button_toggled), this);
	gtk_table_attach_defaults(GTK_TABLE(table), m_AllBtn, 0, 3, row+1, row+2);
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(m_AllBtn));
	m_SelBtn = gtk_radio_button_new_with_label(group, "selected files only");
	gtk_widget_set_tooltip_text(m_SelBtn, "Process frames that are selected in the main window");
	g_signal_connect(G_OBJECT(m_SelBtn), "toggled", G_CALLBACK(button_toggled), this);
	gtk_table_attach_defaults(GTK_TABLE(table), m_SelBtn, 0, 3, row+2, row+3);
	row += 3;

	// Actions
	label = gtk_label_new(NULL);
	gtk_label_set_markup(GTK_LABEL(label), "<b>Execute</b>");
	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
	gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 3, row, row+1);
	row++;

	// Fetch / convert
	m_ConvertBtn = gtk_check_button_new_with_label("Fetch/convert files");
	gtk_widget_set_tooltip_text(m_ConvertBtn, "Start reduction with a fresh copy of the source frames");
	g_signal_connect(G_OBJECT(m_ConvertBtn), "toggled", G_CALLBACK(button_toggled), this);
	gtk_table_attach_defaults(GTK_TABLE(table), m_ConvertBtn, 0, 3, row, row+1);
	m_ChannelCombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(m_Channels));
	gtk_widget_set_tooltip_text(m_ChannelCombo, "Color to grayscale conversion mode");
	renderer = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(m_ChannelCombo), renderer, TRUE);
	gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(m_ChannelCombo), renderer, "text", 1);
	gtk_table_attach(GTK_TABLE(table), m_ChannelCombo, 1, 2, row+1, row+2, 
		(GtkAttachOptions)(GTK_FILL | GTK_SHRINK), GTK_FILL, 0, 0);
	row+=2;

	// Time correction
	if (type==PROJECT_REDUCE || type==PROJECT_COMBINING || type==PROJECT_TEST) {
		m_TimeCorrBtn = gtk_check_button_new_with_label("Time correction");
		gtk_widget_set_tooltip_text(m_TimeCorrBtn, "Adjust the date and time of observation (time correction)");
		g_signal_connect(G_OBJECT(m_TimeCorrBtn), "toggled", G_CALLBACK(button_toggled), this);
		gtk_table_attach_defaults(GTK_TABLE(table), m_TimeCorrBtn, 0, 3, row, row+1);
		m_SecondsEdit = gtk_entry_new();
		gtk_entry_set_editable(GTK_ENTRY(m_SecondsEdit), false);
		gtk_table_attach(GTK_TABLE(table), m_SecondsEdit, 1, 2, row+1, row+2, 
			(GtkAttachOptions)(GTK_FILL | GTK_SHRINK), GTK_FILL, 0, 0);
		m_SecondsBtn = gtk_button_new_with_label("More");
		gtk_widget_set_tooltip_text(m_SecondsBtn, "Specify time correction in a separate dialog");
		g_signal_connect(G_OBJECT(m_SecondsBtn), "clicked", G_CALLBACK(button_clicked), this);
		gtk_table_attach(GTK_TABLE(table), m_SecondsBtn, 2, 3, row+1, row+2, 
			(GtkAttachOptions)(GTK_FILL | GTK_SHRINK), GTK_FILL, 0, 0);
		row+=2;
	}

	// Bias correction
	if (g_Project->Profile()->GetBool(CProfile::ADVANCED_CALIBRATION)) {
		if (type==PROJECT_MASTER_DARK || type==PROJECT_MASTER_FLAT || type==PROJECT_REDUCE || type==PROJECT_COMBINING || type==PROJECT_TEST) {
			m_BiasCorrBtn = gtk_check_button_new_with_label("Bias-frame correction");
			gtk_widget_set_tooltip_text(m_BiasCorrBtn, "Apply the bias correction");
			g_signal_connect(G_OBJECT(m_BiasCorrBtn), "toggled", G_CALLBACK(button_toggled), this);
			gtk_table_attach_defaults(GTK_TABLE(table), m_BiasCorrBtn, 0, 3, row, row+1);
			m_BiasFrameEdit = gtk_entry_new();
			gtk_widget_set_tooltip_text(m_BiasFrameEdit, "Path to the bias frame");
			gtk_table_attach(GTK_TABLE(table), m_BiasFrameEdit, 1, 2, row+1, row+2, 
				(GtkAttachOptions)(GTK_FILL | GTK_EXPAND), GTK_FILL, 0, 0);
			m_BiasFrameBtn = gtk_button_new_with_label("Browse");
			gtk_widget_set_tooltip_text(m_BiasCorrBtn, "Choose a bias frame in a separate dialog");
			g_signal_connect(G_OBJECT(m_BiasFrameBtn), "clicked", G_CALLBACK(button_clicked), this);
			gtk_table_attach(GTK_TABLE(table), m_BiasFrameBtn, 2, 3, row+1, row+2, 
				(GtkAttachOptions)(GTK_FILL | GTK_SHRINK), GTK_FILL, 0, 0);
			row+=2;
		}
	}

	// Dark correction
	if (type==PROJECT_MASTER_FLAT || type==PROJECT_REDUCE || type==PROJECT_COMBINING || type==PROJECT_TEST) {
		m_DarkCorrBtn = gtk_check_button_new_with_label("Dark-frame correction");
		gtk_widget_set_tooltip_text(m_DarkCorrBtn, "Apply the dark correction");
		g_signal_connect(G_OBJECT(m_DarkCorrBtn), "toggled", G_CALLBACK(button_toggled), this);
		gtk_table_attach_defaults(GTK_TABLE(table), m_DarkCorrBtn, 0, 3, row, row+1);
		m_DarkFrameEdit = gtk_entry_new();
		gtk_widget_set_tooltip_text(m_DarkFrameEdit, "Path to the dark frame");
		gtk_table_attach(GTK_TABLE(table), m_DarkFrameEdit, 1, 2, row+1, row+2, 
			(GtkAttachOptions)(GTK_FILL | GTK_EXPAND), GTK_FILL, 0, 0);
		m_DarkFrameBtn = gtk_button_new_with_label("Browse");
		gtk_widget_set_tooltip_text(m_DarkFrameBtn, "Choose a dark frame in a separate dialog");
		g_signal_connect(G_OBJECT(m_DarkFrameBtn), "clicked", G_CALLBACK(button_clicked), this);
		gtk_table_attach(GTK_TABLE(table), m_DarkFrameBtn, 2, 3, row+1, row+2, 
			(GtkAttachOptions)(GTK_FILL | GTK_SHRINK), GTK_FILL, 0, 0);
		row+=2;
	}

	// Flat correction
	if (type==PROJECT_REDUCE || type==PROJECT_COMBINING || type==PROJECT_TEST) {
		m_FlatCorrBtn = gtk_check_button_new_with_label("Flat-frame correction");
		gtk_widget_set_tooltip_text(m_FlatCorrBtn, "Apply the flat correction");
		g_signal_connect(G_OBJECT(m_FlatCorrBtn), "toggled", G_CALLBACK(button_toggled), this);
		gtk_table_attach_defaults(GTK_TABLE(table), m_FlatCorrBtn, 0, 3, row, row+1);
		m_FlatFrameEdit = gtk_entry_new();
		gtk_widget_set_tooltip_text(m_FlatFrameEdit, "Path to the flat frame");
		gtk_table_attach(GTK_TABLE(table), m_FlatFrameEdit, 1, 2, row+1, row+2, 
			(GtkAttachOptions)(GTK_FILL | GTK_EXPAND), GTK_FILL, 0, 0);
		m_FlatFrameBtn = gtk_button_new_with_label("Browse");
		gtk_widget_set_tooltip_text(m_FlatFrameBtn, "Choose a flat frame in a separate dialog");
		g_signal_connect(G_OBJECT(m_FlatFrameBtn), "clicked", G_CALLBACK(button_clicked), this);
		gtk_table_attach(GTK_TABLE(table), m_FlatFrameBtn, 2, 3, row+1, row+2,
			(GtkAttachOptions)(GTK_FILL | GTK_SHRINK), GTK_FILL, 0, 0);
		row+=2;
	}

	// Photometry
	if (type==PROJECT_REDUCE || type==PROJECT_COMBINING || type==PROJECT_TEST) {
		m_PhotometryBtn = gtk_check_button_new_with_label("Photometry");
		gtk_widget_set_tooltip_text(m_PhotometryBtn, "Run photometry");
		g_signal_connect(G_OBJECT(m_PhotometryBtn), "toggled", G_CALLBACK(button_toggled), this);
		gtk_table_attach_defaults(GTK_TABLE(table), m_PhotometryBtn, 0, 3, row, row+1);
		row++;
	}

	// Matching
	if (type==PROJECT_REDUCE || type==PROJECT_COMBINING || type==PROJECT_TEST) {
		m_MatchingBtn = gtk_check_button_new_with_label("Matching");
		gtk_widget_set_tooltip_text(m_MatchingBtn, "Run matching");
		g_signal_connect(G_OBJECT(m_MatchingBtn), "toggled", G_CALLBACK(button_toggled), this);
		gtk_table_attach_defaults(GTK_TABLE(table), m_MatchingBtn, 0, 3, row, row+1);

		m_RefBtn = gtk_radio_button_new_with_label(NULL, "using reference frame");
		gtk_widget_set_tooltip_text(m_RefBtn, "Use one of the source frames as a reference frame");
		g_signal_connect(G_OBJECT(m_RefBtn), "toggled", G_CALLBACK(button_toggled), this);
		gtk_table_attach_defaults(GTK_TABLE(table), m_RefBtn, 1, 3, row+1, row+2);

		m_RefFrameCombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(m_Frames));
		gtk_widget_set_tooltip_text(m_RefFrameCombo, "A frame that shall be used as a reference frame");
		renderer = gtk_cell_renderer_text_new();
		gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(m_RefFrameCombo), renderer, TRUE);
		gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(m_RefFrameCombo), renderer, "text", 1);
		gtk_table_attach(GTK_TABLE(table), m_RefFrameCombo, 1, 2, row+2, row+3, 
			(GtkAttachOptions)(GTK_FILL | GTK_EXPAND), GTK_FILL, 0, 0);
		m_RefFrameBtn = gtk_button_new_with_label("Browse");
		gtk_widget_set_tooltip_text(m_RefFrameBtn, "Choose a reference frame in a separate dialog");
		g_signal_connect(G_OBJECT(m_RefFrameBtn), "clicked", G_CALLBACK(button_clicked), this);
		gtk_table_attach(GTK_TABLE(table), m_RefFrameBtn, 2, 3, row+2, row+3, 
			(GtkAttachOptions)(GTK_FILL | GTK_SHRINK), GTK_FILL, 0, 0);

		group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(m_RefBtn));
		m_CatBtn = gtk_radio_button_new_with_label(group, "using catalog file");
		gtk_widget_set_tooltip_text(m_CatBtn, "Use a catalog file as a reference frame");
		g_signal_connect(G_OBJECT(m_CatBtn), "toggled", G_CALLBACK(button_toggled), this);
		gtk_table_attach_defaults(GTK_TABLE(table), m_CatBtn, 1, 3, row+3, row+4);

		m_CatFrameEdit = gtk_entry_new();
		gtk_widget_set_tooltip_text(m_CatFrameEdit, "Path to the catalog file that shall be used as a reference frame");
		gtk_table_attach(GTK_TABLE(table), m_CatFrameEdit, 1, 2, row+4, row+5, 
			(GtkAttachOptions)(GTK_FILL | GTK_EXPAND), GTK_FILL, 0, 0);
		m_CatFrameBtn = gtk_button_new_with_label("Browse");
		gtk_widget_set_tooltip_text(m_CatFrameBtn, "Choose a catalog file in a separate dialog");
		g_signal_connect(G_OBJECT(m_CatFrameBtn), "clicked", G_CALLBACK(button_clicked), this);
		gtk_table_attach(GTK_TABLE(table), m_CatFrameBtn, 2, 3, row+4, row+5, 
			(GtkAttachOptions)(GTK_FILL | GTK_SHRINK), GTK_FILL, 0, 0);
		row+=5;
	}

	gtk_widget_show_all(GTK_DIALOG(m_pDlg)->vbox);
}
Esempio n. 8
0
static void
setup_protocol (VinagreConnectDialog *dialog)
{
  GHashTable      *extensions;
  GHashTableIter  hash_iter;
  gpointer        key, value;
  GtkTreeIter     tree_iter;
  GtkCellRenderer *rend;
  gchar           *last_protocol;
  gint            selected, i;

  dialog->protocol_store = gtk_list_store_new (N_PROTOCOLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_OBJECT, G_TYPE_OBJECT);
  extensions = vinagre_plugins_engine_get_plugins_by_protocol (vinagre_plugins_engine_get_default ());
  last_protocol = vinagre_cache_prefs_get_string ("connection", "last-protocol", NULL);

  g_hash_table_iter_init (&hash_iter, extensions);
  selected = 0;
  i = 0;
  while (g_hash_table_iter_next (&hash_iter, &key, &value)) 
    {
      gchar **description;
      GtkWidget *widget;
      VinagreProtocol *ext =  (VinagreProtocol *)value;

      description = vinagre_protocol_get_public_description (ext);
      if (!description || !description[0])
	continue;

      widget = vinagre_protocol_get_connect_widget (ext, NULL);

      gtk_list_store_append (dialog->protocol_store, &tree_iter);
      gtk_list_store_set (dialog->protocol_store, &tree_iter,
			  PROTOCOL_NAME, description[0],
			  PROTOCOL_DESCRIPTION, description[1],
			  PROTOCOL_MDNS, vinagre_protocol_get_mdns_service (ext),
			  PROTOCOL_OPTIONS, widget,
			  PROTOCOL_PLUGIN, ext,
			  -1);

      if (last_protocol && g_str_equal (last_protocol, description[0]))
        selected = i;

      g_strfreev (description);
      if (widget)
	g_object_unref (widget);
      i++;
    }

  gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->protocol_combo),
			   GTK_TREE_MODEL (dialog->protocol_store));
  rend = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->protocol_combo), rend, TRUE);
  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (dialog->protocol_combo), rend, "text", 0);

  g_signal_connect (dialog->protocol_combo,
		    "changed",
		    G_CALLBACK (protocol_combo_changed),
		    dialog);
  gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->protocol_combo), selected);
  g_free (last_protocol);
}
Esempio n. 9
0
static void build_drmr_ui(DrMrUi* ui) {
  GtkWidget *drmr_ui_widget;
  GtkWidget *opts_hbox1, *opts_hbox2, 
    *kit_combo_box, *kit_label, *no_kit_label,
    *base_label, *base_spin, *position_label, *position_combo_box;
  GtkCellRenderer *cell_rend;
  GtkAdjustment *base_adj;
  
  drmr_ui_widget = gtk_vbox_new(false,0);
  g_object_set(drmr_ui_widget,"border-width",6,NULL);

  ui->kit_store = gtk_list_store_new(1,G_TYPE_STRING);

  opts_hbox1 = gtk_hbox_new(false,0);
  opts_hbox2 = gtk_hbox_new(false,0);
  kit_combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(ui->kit_store));
  kit_label = gtk_label_new("Kit:");

  no_kit_label = gtk_label_new("<b>No/Invalid Kit Selected</b>");
  gtk_label_set_use_markup(GTK_LABEL(no_kit_label),true);

  cell_rend = gtk_cell_renderer_text_new();
  gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(kit_combo_box), cell_rend, true);
  gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(kit_combo_box), cell_rend,"text",0,NULL);

  base_label = gtk_label_new("Midi Base Note <b>(C 2)</b>:");
  gtk_label_set_use_markup(GTK_LABEL(base_label),true);
  base_adj = GTK_ADJUSTMENT
    (gtk_adjustment_new(36.0, // val
			21.0,107.0, // min/max
			1.0, // step
			5.0,0.0)); // page adj/size
  base_spin = gtk_spin_button_new(base_adj, 1.0, 0);

  position_label = gtk_label_new("Sample Zero Position: ");
  position_combo_box = create_position_combo();

  ui->velocity_checkbox = gtk_check_button_new_with_label("Ignore Velocity");
  ui->note_off_checkbox = gtk_check_button_new_with_label("Ignore Note Off");

  gtk_box_pack_start(GTK_BOX(opts_hbox1),kit_label,
		     false,false,15);
  gtk_box_pack_start(GTK_BOX(opts_hbox1),no_kit_label,
		     true,true,0);
  gtk_box_pack_start(GTK_BOX(opts_hbox1),kit_combo_box,
		     true,true,0);
  gtk_box_pack_start(GTK_BOX(opts_hbox1),base_label,
		     false,false,15);
  gtk_box_pack_start(GTK_BOX(opts_hbox1),base_spin,
		     true,true,0);

  gtk_box_pack_start(GTK_BOX(opts_hbox2),position_label,
		     false,false,15);
  gtk_box_pack_start(GTK_BOX(opts_hbox2),position_combo_box,
		     false,false,0);
  gtk_box_pack_start(GTK_BOX(opts_hbox2),ui->velocity_checkbox,
		     true,true,15);
  gtk_box_pack_start(GTK_BOX(opts_hbox2),ui->note_off_checkbox,
		     true,true,15);

  gtk_box_pack_start(GTK_BOX(drmr_ui_widget),gtk_hseparator_new(),
		     false,false,5);
  gtk_box_pack_start(GTK_BOX(drmr_ui_widget),opts_hbox1,
		     false,false,5);
  gtk_box_pack_start(GTK_BOX(drmr_ui_widget),opts_hbox2,
		     false,false,5);



  ui->drmr_widget = drmr_ui_widget;
  ui->sample_table = NULL;
  ui->kit_combo = GTK_COMBO_BOX(kit_combo_box);
  ui->base_label = GTK_LABEL(base_label);
  ui->base_spin = GTK_SPIN_BUTTON(base_spin);
  ui->no_kit_label = no_kit_label;

  g_signal_connect(G_OBJECT(kit_combo_box),"changed",G_CALLBACK(kit_combobox_changed),ui);
  g_signal_connect(G_OBJECT(base_spin),"value-changed",G_CALLBACK(base_changed),ui);
  g_signal_connect(G_OBJECT(position_combo_box),"changed",G_CALLBACK(position_combobox_changed),ui);
  g_signal_connect(G_OBJECT(ui->velocity_checkbox),"toggled",G_CALLBACK(ignore_velocity_toggled),ui);
  g_signal_connect(G_OBJECT(ui->note_off_checkbox),"toggled",G_CALLBACK(ignore_note_off_toggled),ui);

  gtk_widget_show_all(drmr_ui_widget);
  gtk_widget_hide(no_kit_label);
}
Esempio n. 10
0
static void
setup_main_window (UmUserPanelPrivate *d)
{
        GtkWidget *userlist;
        GtkTreeModel *model;
        GtkListStore *store;
        GtkTreeViewColumn *column;
        GtkCellRenderer *cell;
        GtkTreeSelection *selection;
        GtkWidget *button;
        GtkTreeIter iter;
        gint expander_size;
        gchar *title;
        GIcon *icon;
        gchar *names[3];

        userlist = get_widget (d, "list-treeview");
        store = gtk_list_store_new (NUM_USER_LIST_COLS,
                                    UM_TYPE_USER,
                                    GDK_TYPE_PIXBUF,
                                    G_TYPE_STRING,
                                    G_TYPE_BOOLEAN,
                                    G_TYPE_STRING,
                                    G_TYPE_BOOLEAN,
                                    G_TYPE_INT,
                                    G_TYPE_BOOLEAN);
        model = (GtkTreeModel *)store;
        gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (model), sort_users, NULL, NULL);
        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
        gtk_tree_view_set_model (GTK_TREE_VIEW (userlist), model);
        gtk_tree_view_set_search_column (GTK_TREE_VIEW (userlist), USER_COL);
        gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (userlist),
                                             match_user, NULL, NULL);
        g_object_unref (model);

        g_signal_connect (d->um, "users-loaded", G_CALLBACK (users_loaded), d);

        gtk_widget_style_get (userlist, "expander-size", &expander_size, NULL);
        gtk_tree_view_set_level_indentation (GTK_TREE_VIEW (userlist), - (expander_size + 6));

        title = g_strdup_printf ("<small><span foreground=\"#555555\">%s</span></small>", _("My Account"));
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            TITLE_COL, title,
                            HEADING_ROW_COL, TRUE,
                            SORT_KEY_COL, 0,
                            AUTOLOGIN_COL, FALSE,
                            -1);
        g_free (title);

        title = g_strdup_printf ("<small><span foreground=\"#555555\">%s</span></small>", _("Other Accounts"));
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            TITLE_COL, title,
                            HEADING_ROW_COL, TRUE,
                            SORT_KEY_COL, 2,
                            AUTOLOGIN_COL, FALSE,
                            -1);
        g_free (title);

        column = gtk_tree_view_column_new ();
        cell = gtk_cell_renderer_pixbuf_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), cell, FALSE);
        gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), cell, "pixbuf", FACE_COL);
        gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), cell, "visible", USER_ROW_COL);
        cell = gtk_cell_renderer_text_new ();
        g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), cell, TRUE);
        gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), cell, "markup", NAME_COL);
        gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), cell, "visible", USER_ROW_COL);
        cell = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), cell, TRUE);
        gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), cell, "markup", TITLE_COL);
        gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), cell, "visible", HEADING_ROW_COL);
        cell = gtk_cell_renderer_pixbuf_new ();
        gtk_tree_view_column_pack_start (column, cell, FALSE);
        gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (column), cell, "visible", USER_ROW_COL);
        gtk_tree_view_column_set_cell_data_func (column,
                                                 cell,
                                                 (GtkTreeCellDataFunc) autologin_cell_data_func,
                                                 d,
                                                 NULL);

        gtk_tree_view_append_column (GTK_TREE_VIEW (userlist), column);

        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (userlist));
        gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
        g_signal_connect (selection, "changed", G_CALLBACK (selected_user_changed), d);
        gtk_tree_selection_set_select_function (selection, dont_select_headings, NULL, NULL);

        gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (get_widget (d, "list-scrolledwindow")), 300);
        gtk_widget_set_size_request (get_widget (d, "list-scrolledwindow"), 200, -1);

        button = get_widget (d, "add-user-toolbutton");
        g_signal_connect (button, "clicked", G_CALLBACK (add_user), d);

        button = get_widget (d, "remove-user-toolbutton");
        g_signal_connect (button, "clicked", G_CALLBACK (delete_user), d);

        button = get_widget (d, "user-icon-nonbutton");
        add_unlock_tooltip (button);

        button = get_widget (d, "full-name-entry");
        g_signal_connect (button, "editing-done", G_CALLBACK (change_name_done), d);

        button = get_widget (d, "account-type-combo");
        g_signal_connect (button, "editing-done", G_CALLBACK (account_type_changed), d);

        button = get_widget (d, "account-password-button");
        g_signal_connect (button, "start-editing", G_CALLBACK (change_password), d);

        button = get_widget (d, "account-language-combo");
        g_signal_connect (button, "editing-done", G_CALLBACK (language_changed), d);

        button = get_widget (d, "autologin-switch");
        g_signal_connect (button, "notify::active", G_CALLBACK (autologin_changed), d);

        button = get_widget (d, "account-fingerprint-button");
        g_signal_connect (button, "clicked",
                          G_CALLBACK (change_fingerprint), d);

        d->permission = (GPermission *)polkit_permission_new_sync ("org.freedesktop.accounts.user-administration", NULL, NULL, NULL);
        g_signal_connect (d->permission, "notify",
                          G_CALLBACK (on_permission_changed), d);
        on_permission_changed (d->permission, NULL, d);

        button = get_widget (d, "add-user-toolbutton");
        names[0] = "changes-allow-symbolic";
        names[1] = "changes-allow";
        names[2] = NULL;
        icon = (GIcon *)g_themed_icon_new_from_names (names, -1);
        setup_tooltip_with_embedded_icon (button,
                                          _("To create a user account,\nclick the * icon first"),
                                          "*",
                                          icon);
        button = get_widget (d, "remove-user-toolbutton");
        setup_tooltip_with_embedded_icon (button,
                                          _("To delete the selected user account,\nclick the * icon first"),
                                          "*",
                                          icon);
        g_object_unref (icon);
}
Esempio n. 11
0
void
seahorse_gpgme_add_subkey_new (SeahorseGpgmeKey *pkey, GtkWindow *parent)
{
	SeahorseWidget *swidget;
	GtkComboBox* combo;
	GtkTreeModel *model;
	GtkTreeIter iter;
	GtkCellRenderer *renderer;
	GtkWidget *widget, *datetime;

	swidget = seahorse_object_widget_new ("add-subkey", parent, G_OBJECT (pkey));
	g_return_if_fail (swidget != NULL);
	
	gtk_window_set_title (GTK_WINDOW (seahorse_widget_get_widget (swidget, swidget->name)),
		g_strdup_printf (_("Add subkey to %s"), seahorse_object_get_label (SEAHORSE_OBJECT (pkey))));
    
    combo = GTK_COMBO_BOX (seahorse_widget_get_widget (swidget, "type"));
    model = GTK_TREE_MODEL (gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_INT));
    
    gtk_combo_box_set_model (combo, model);
        
    gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo));
    renderer = gtk_cell_renderer_text_new ();
    
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
    gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer,
                                    "text", COMBO_STRING);
                                    
    gtk_list_store_append (GTK_LIST_STORE (model), &iter);
    gtk_list_store_set (GTK_LIST_STORE (model), &iter,
                        COMBO_STRING, _("DSA (sign only)"),
                        COMBO_INT, 0,
                        -1);
                        
    gtk_combo_box_set_active_iter (combo, &iter);
    
    gtk_list_store_append (GTK_LIST_STORE (model), &iter);
    gtk_list_store_set (GTK_LIST_STORE (model), &iter,
                        COMBO_STRING, _("ElGamal (encrypt only)"),
                        COMBO_INT, 1,
                        -1);
                        
	gtk_list_store_append (GTK_LIST_STORE (model), &iter);
    gtk_list_store_set (GTK_LIST_STORE (model), &iter,
                        COMBO_STRING, _("RSA (sign only)"),
                        COMBO_INT, 2,
                        -1);
    
	gtk_list_store_append (GTK_LIST_STORE (model), &iter);
    gtk_list_store_set (GTK_LIST_STORE (model), &iter,
                        COMBO_STRING, _("RSA (encrypt only)"),
                        COMBO_INT, 3,
                        -1);
    
	widget = seahorse_widget_get_widget (swidget, "datetime-placeholder");
	g_return_if_fail (widget != NULL);

	datetime = egg_datetime_new ();
	gtk_container_add (GTK_CONTAINER (widget), datetime);
	gtk_widget_show (datetime);
	gtk_widget_set_sensitive (datetime, FALSE);
	g_object_set_data (G_OBJECT (swidget), "expires-datetime", datetime);
}
Esempio n. 12
0
void
gevo_add_buddy_dialog_show(PurpleAccount *account, const char *username,
						   const char *group, const char *alias)
{
	GevoAddBuddyDialog *dialog;
	GtkWidget *button;
	GtkWidget *sw;
	GtkWidget *label;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *bbox;
	GtkWidget *sep;
	GtkTreeSelection *selection;
	GtkCellRenderer *cell;

	dialog = g_new0(GevoAddBuddyDialog, 1);

	dialog->account =
		(account != NULL
		 ? account
		 : purple_connection_get_account(purple_connections_get_all()->data));

	if (username != NULL)
		dialog->username = g_strdup(username);

	dialog->win = pidgin_create_window(_("Add Buddy"), PIDGIN_HIG_BORDER, "add_buddy", TRUE);
	gtk_widget_set_size_request(dialog->win, -1, 400);

	g_signal_connect(G_OBJECT(dialog->win), "delete_event",
					 G_CALLBACK(delete_win_cb), dialog);

	/* Setup the vbox */
	vbox = gtk_vbox_new(FALSE, 12);
	gtk_container_add(GTK_CONTAINER(dialog->win), vbox);
	gtk_widget_show(vbox);

	/* Add the label. */
	label = gtk_label_new(_("Select a person from your address book below, "
							"or add a new person."));
	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
	gtk_widget_show(label);

	/* Add the search hbox */
	hbox = gtk_hbox_new(FALSE, 6);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
	gtk_widget_show(hbox);

	/* "Search" */
	label = gtk_label_new(_("Search"));
	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
	gtk_widget_show(label);

	/* Addressbooks */
	dialog->addrbooks = gevo_addrbooks_model_new();

	dialog->addrbooks_combo = gtk_combo_box_new_with_model(
			dialog->addrbooks);
	cell = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dialog->addrbooks_combo),
							   cell, TRUE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dialog->addrbooks_combo),
								   cell,
								   "text", ADDRBOOK_COLUMN_NAME,
								   NULL);
	gtk_box_pack_start(GTK_BOX(hbox), dialog->addrbooks_combo, FALSE,
					   FALSE, 0);
	gtk_widget_show(dialog->addrbooks_combo);

	/* Search field */
	dialog->search_field = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX(hbox), dialog->search_field, TRUE, TRUE, 0);
	gtk_widget_show(dialog->search_field);

	g_signal_connect(G_OBJECT(dialog->search_field), "changed",
					 G_CALLBACK(search_changed_cb), dialog);

	/* Clear button */
	button = gtk_button_new_from_stock(GTK_STOCK_CLEAR);
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
	gtk_widget_show(button);

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(clear_cb), dialog);

	/* Scrolled Window */
	sw = gtk_scrolled_window_new(0, 0);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
								   GTK_POLICY_AUTOMATIC,
								   GTK_POLICY_ALWAYS);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
										GTK_SHADOW_IN);
	gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
	gtk_widget_show(sw);

	/* Create the list model for the treeview. */
	dialog->model = gtk_list_store_new(NUM_COLUMNS,
									   G_TYPE_STRING, GDK_TYPE_PIXBUF,
									   G_TYPE_STRING, G_TYPE_POINTER);

	/* Now for the treeview */
	dialog->treeview =
		gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model));
	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(dialog->treeview), TRUE);
	gtk_container_add(GTK_CONTAINER(sw), dialog->treeview);
	gtk_widget_show(dialog->treeview);

	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));

	gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);

	g_signal_connect(G_OBJECT(selection), "changed",
					 G_CALLBACK(selected_cb), dialog);

	add_columns(dialog);

	/*
	 * Catch addressbook selection and populate treeview with the first
	 * addressbook
	 */
	gevo_addrbooks_model_populate(dialog->addrbooks);
	g_signal_connect(G_OBJECT(dialog->addrbooks_combo), "changed",
							  G_CALLBACK(addrbook_change_cb), dialog);
	gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->addrbooks_combo), 0);

	/* Group box */
	hbox = gtk_hbox_new(FALSE, 6);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
	gtk_widget_show(hbox);

	label = gtk_label_new(_("Group:"));
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
	gtk_widget_show(label);

	dialog->group_combo =
		pidgin_text_combo_box_entry_new(NULL, gevo_get_groups());
	gtk_box_pack_start(GTK_BOX(hbox), dialog->group_combo, TRUE, TRUE, 0);
	gtk_widget_show(dialog->group_combo);

	/* Cool. Now we only have a little left... */

	/* Separator. */
	sep = gtk_hseparator_new();
	gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
	gtk_widget_show(sep);

	/* Button box */
	bbox = gtk_hbutton_box_new();
	gtk_box_set_spacing(GTK_BOX(bbox), 6);
	gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
	gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
	gtk_widget_show(bbox);

	/* "New Person" button */
	button = pidgin_pixbuf_button_from_stock(_("New Person"), GTK_STOCK_NEW,
										   PIDGIN_BUTTON_HORIZONTAL);
	gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
	gtk_widget_show(button);

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(new_person_cb), dialog);

	/* "Cancel" button */
	button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
	gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
	gtk_widget_show(button);

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(cancel_cb), dialog);

	/* "Select Buddy" button */
	button = pidgin_pixbuf_button_from_stock(_("Select Buddy"), GTK_STOCK_APPLY,
										   PIDGIN_BUTTON_HORIZONTAL);
	dialog->select_button = button;
	gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
	gtk_widget_set_sensitive(button, FALSE);
	gtk_widget_show(button);

	g_signal_connect(G_OBJECT(button), "clicked",
					 G_CALLBACK(select_buddy_cb), dialog);

	/* Show it. */
	gtk_widget_show(dialog->win);
}
Esempio n. 13
0
void
dlg_import_from_flickr (FlickrServer *server,
		        GthBrowser   *browser)
{
	DialogData     *data;
	GthThumbLoader *thumb_loader;
	char           *title;

	data = g_new0 (DialogData, 1);
	data->server = server;
	data->browser = browser;
	data->location = gth_file_data_dup (gth_browser_get_location_data (browser));
	data->builder = _gtk_builder_new_from_file ("import-from-flickr.ui", "flicker_utils");
	data->dialog = _gtk_builder_get_widget (data->builder, "import_dialog");
	data->cancellable = g_cancellable_new ();

	{
		GtkCellLayout   *cell_layout;
		GtkCellRenderer *renderer;

		cell_layout = GTK_CELL_LAYOUT (GET_WIDGET ("photoset_combobox"));

		renderer = gtk_cell_renderer_pixbuf_new ();
		gtk_cell_layout_pack_start (cell_layout, renderer, FALSE);
		gtk_cell_layout_set_attributes (cell_layout, renderer,
						"icon-name", PHOTOSET_ICON_COLUMN,
						NULL);

		renderer = gtk_cell_renderer_text_new ();
		gtk_cell_layout_pack_start (cell_layout, renderer, TRUE);
		gtk_cell_layout_set_attributes (cell_layout, renderer,
						"text", PHOTOSET_TITLE_COLUMN,
						NULL);

		renderer = gtk_cell_renderer_text_new ();
		gtk_cell_layout_pack_start (cell_layout, renderer, FALSE);
		gtk_cell_layout_set_attributes (cell_layout, renderer,
						"text", PHOTOSET_N_PHOTOS_COLUMN,
						NULL);
	}

	/* Set the widget data */

	data->file_list = gth_file_list_new (gth_grid_view_new (), GTH_FILE_LIST_MODE_NORMAL, FALSE);
	thumb_loader = gth_file_list_get_thumb_loader (GTH_FILE_LIST (data->file_list));
	gth_thumb_loader_set_use_cache (thumb_loader, FALSE);
	gth_thumb_loader_set_loader_func (thumb_loader, flickr_thumbnail_loader);
	gth_file_list_set_thumb_size (GTH_FILE_LIST (data->file_list), FLICKR_SIZE_THUMBNAIL);
	gth_file_list_enable_thumbs (GTH_FILE_LIST (data->file_list), TRUE);
	gth_file_list_set_ignore_hidden (GTH_FILE_LIST (data->file_list), TRUE);
	gth_file_list_set_caption (GTH_FILE_LIST (data->file_list), "none");
	gth_file_list_set_sort_func (GTH_FILE_LIST (data->file_list), flickr_photo_position_func, FALSE);
	gth_file_list_clear (GTH_FILE_LIST (data->file_list), _("No album selected"));
	gtk_widget_show (data->file_list);
	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("images_box")), data->file_list, TRUE, TRUE, 0);

	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GET_WIDGET ("photoset_liststore")), PHOTOSET_TITLE_COLUMN, GTK_SORT_ASCENDING);

	gtk_widget_set_sensitive (GET_WIDGET ("download_button"), FALSE);

	data->preferences_dialog = gth_import_preferences_dialog_new ();
	gtk_window_set_transient_for (GTK_WINDOW (data->preferences_dialog), GTK_WINDOW (data->dialog));

	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("destination_button_box")),
			    gth_import_destination_button_new (GTH_IMPORT_PREFERENCES_DIALOG (data->preferences_dialog)),
			    TRUE,
			    TRUE,
			    0);
	gtk_widget_show_all (GET_WIDGET ("destination_button_box"));

	title = g_strdup_printf (_("Import from %s"), data->server->display_name);
	gtk_window_set_title (GTK_WINDOW (data->dialog), title);
	g_free (title);

	_gtk_window_resize_to_fit_screen_height (data->dialog, 500);

	/* Set the signals handlers. */

	g_signal_connect (data->dialog,
			  "destroy",
			  G_CALLBACK (import_dialog_destroy_cb),
			  data);
	g_signal_connect (data->dialog,
			  "delete-event",
			  G_CALLBACK (gtk_true),
			  NULL);
	g_signal_connect (data->dialog,
			  "response",
			  G_CALLBACK (import_dialog_response_cb),
			  data);
	g_signal_connect (GET_WIDGET ("edit_accounts_button"),
			  "clicked",
			  G_CALLBACK (edit_accounts_button_clicked_cb),
			  data);
	g_signal_connect (GET_WIDGET ("account_combobox"),
			  "changed",
			  G_CALLBACK (account_combobox_changed_cb),
			  data);
	g_signal_connect (GET_WIDGET ("photoset_combobox"),
			  "changed",
			  G_CALLBACK (photoset_combobox_changed_cb),
			  data);
	g_signal_connect (gth_file_list_get_view (GTH_FILE_LIST (data->file_list)),
			  "file-selection-changed",
			  G_CALLBACK (file_list_selection_changed_cb),
			  data);

	update_selection_status (data);
	gth_import_preferences_dialog_set_event (GTH_IMPORT_PREFERENCES_DIALOG (data->preferences_dialog), "");

	data->service = flickr_service_new (server,
					    data->cancellable,
					    GTK_WIDGET (data->browser),
					    data->dialog);
	g_signal_connect (data->service,
			  "account-ready",
			  G_CALLBACK (authentication_ready_cb),
			  data);
	g_signal_connect (data->service,
			  "accounts-changed",
			  G_CALLBACK (authentication_accounts_changed_cb),
			  data);

	data->progress_dialog = gth_progress_dialog_new (GTK_WINDOW (data->browser));
	gth_progress_dialog_add_task (GTH_PROGRESS_DIALOG (data->progress_dialog), GTH_TASK (data->service));

	web_service_autoconnect (WEB_SERVICE (data->service));
}
Esempio n. 14
0
GtkWidget *
status_menu_new (Ekiga::ServiceCore & core)
{
    StatusMenu *self = NULL;

    sigc::connection conn;
    GtkCellRenderer *renderer = NULL;
    GSList *custom_status_array [NUM_STATUS_TYPES];

    self = (StatusMenu *) g_object_new (STATUS_MENU_TYPE, NULL);
    self->priv = new StatusMenuPrivate ();

    self->priv->personal_details = core.get ("personal-details");
    self->priv->parent = NULL;
    self->priv->list_store = gtk_list_store_new (NUM_COLUMNS,
                             GDK_TYPE_PIXBUF,
                             G_TYPE_STRING,
                             G_TYPE_INT,
                             G_TYPE_BOOLEAN);

    gtk_combo_box_set_model (GTK_COMBO_BOX (self),
                             GTK_TREE_MODEL (self->priv->list_store));
    g_object_unref (self->priv->list_store);

    renderer = gtk_cell_renderer_pixbuf_new ();
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self), renderer, FALSE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self), renderer,
                                    "pixbuf", COL_ICON, NULL);

    renderer = gtk_cell_renderer_text_new ();
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self), renderer, FALSE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self), renderer, "text", COL_MESSAGE, NULL);
    g_object_set (renderer, "width", 130,
                  "ellipsize-set", true,
                  "ellipsize", PANGO_ELLIPSIZE_END, NULL);

    for (int i = 0 ; i < NUM_STATUS_TYPES ; i++)
        custom_status_array [i] = gm_conf_get_string_list (status_types_keys [i]);

    status_menu_populate (self, custom_status_array);

    for (int i = 0 ; i < NUM_STATUS_TYPES ; i++) {
        g_slist_foreach (custom_status_array [i], (GFunc) g_free, 0);
        g_slist_free (custom_status_array [i]);
    }

    gtk_combo_box_set_active (GTK_COMBO_BOX (self), 0);

    gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (self),
                                          (GtkTreeViewRowSeparatorFunc) status_menu_row_is_separator,
                                          NULL, NULL);
    gtk_container_set_border_width (GTK_CONTAINER (self), 0);
    status_menu_set_option (self, self->priv->personal_details->get_presence (), self->priv->personal_details->get_status ());

    g_signal_connect (G_OBJECT (self), "changed",
                      G_CALLBACK (status_menu_option_changed), self);

    gm_conf_notifier_add (PERSONAL_DATA_KEY "online_custom_status",
                          status_menu_custom_messages_changed, self);
    gm_conf_notifier_add (PERSONAL_DATA_KEY "away_custom_status",
                          status_menu_custom_messages_changed, self);
    gm_conf_notifier_add (PERSONAL_DATA_KEY "dnd_custom_status",
                          status_menu_custom_messages_changed, self);

    conn = self->priv->personal_details->updated.connect (sigc::bind (sigc::ptr_fun (on_details_updated), self));
    self->priv->connections.push_back (conn);

    return GTK_WIDGET (self);
}
/**
 * empathy_account_widget_irc_new:
 * @account: the #McAccount to configure
 *
 * Creates a new IRC account widget to configure a given #McAccount
 *
 * Returns: The toplevel container of the configuration widget
 */
GtkWidget *
empathy_account_widget_irc_new (McAccount *account)
{
  EmpathyAccountWidgetIrc *settings;
  gchar *dir, *user_file_with_path, *global_file_with_path;
  GladeXML *glade;
  GtkListStore *store;
  GtkCellRenderer *renderer;
  gchar *filename;

  settings = g_slice_new0 (EmpathyAccountWidgetIrc);
  settings->account = g_object_ref (account);

  dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
  g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
  user_file_with_path = g_build_filename (dir, IRC_NETWORKS_FILENAME, NULL);
  g_free (dir);

  global_file_with_path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"),
      "libempathy-gtk", IRC_NETWORKS_FILENAME, NULL);
  if (!g_file_test (global_file_with_path, G_FILE_TEST_EXISTS))
    {
      g_free (global_file_with_path);
      global_file_with_path = g_build_filename (DATADIR, "empathy",
          IRC_NETWORKS_FILENAME, NULL);
    }

  settings->network_manager = empathy_irc_network_manager_new (
      global_file_with_path,
      user_file_with_path);

  g_free (global_file_with_path);
  g_free (user_file_with_path);

  filename = empathy_file_lookup ("empathy-account-widget-irc.glade",
      "libempathy-gtk");
  glade = empathy_glade_get_file (filename,
      "vbox_irc_settings",
      NULL,
      "vbox_irc_settings", &settings->vbox_settings,
      "combobox_network", &settings->combobox_network,
      "button_network", &settings->button_network,
      "button_add_network", &settings->button_add_network,
      "button_remove", &settings->button_remove,
      NULL);
  g_free (filename);

  /* Fill the networks combobox */
  store = gtk_list_store_new (2, G_TYPE_OBJECT, G_TYPE_STRING);

  gtk_cell_layout_clear (GTK_CELL_LAYOUT (settings->combobox_network)); 
  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (settings->combobox_network),
      renderer, TRUE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (settings->combobox_network),
      renderer,
      "text", COL_NETWORK_NAME,
      NULL);

  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
      COL_NETWORK_NAME,
      GTK_SORT_ASCENDING);

  gtk_combo_box_set_model (GTK_COMBO_BOX (settings->combobox_network),
      GTK_TREE_MODEL (store));
  g_object_unref (store);

  account_widget_irc_setup (settings);

  empathy_account_widget_handle_params (account, glade,
      "entry_nick", "account",
      "entry_fullname", "fullname",
      "entry_password", "password",
      "entry_quit_message", "quit-message",
      NULL);

  empathy_glade_connect (glade, settings,
      "vbox_irc_settings", "destroy", account_widget_irc_destroy_cb,
      "button_network", "clicked", account_widget_irc_button_edit_network_clicked_cb,
      "button_add_network", "clicked", account_widget_irc_button_add_network_clicked_cb,
      "button_remove", "clicked", account_widget_irc_button_remove_clicked_cb,
      "combobox_network", "changed", account_widget_irc_combobox_network_changed_cb,
      NULL);

  g_object_unref (glade);

  return settings->vbox_settings;
}
Esempio n. 16
0
static void
gth_slideshow_preferences_construct (GthSlideshowPreferences *self,
				     const char              *current_transition,
				     gboolean                 automatic,
				     int                      delay,
				     gboolean                 wrap_around,
				     gboolean                 random_order)
{
	GtkListStore    *model;
	GtkCellRenderer *renderer;
	GList           *transitions;
	int              i, i_active;
	GList           *scan;
	GtkTreeIter      iter;

	self->priv->builder = _gtk_builder_new_from_file ("slideshow-preferences.ui", "slideshow");
	gtk_container_add (GTK_CONTAINER (self), _gtk_builder_get_widget (self->priv->builder, "preferences_page"));

	model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
	self->priv->transition_combobox = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model));
	g_object_unref (model);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self->priv->transition_combobox),
				    renderer,
				    TRUE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self->priv->transition_combobox),
					renderer,
					"text", TRANSITION_COLUMN_DISPLAY_NAME,
					NULL);

	transitions = gth_main_get_registered_objects (GTH_TYPE_TRANSITION);
	for (i = 0, i_active = 0, scan = transitions; scan; scan = scan->next, i++) {
		GthTransition *transition = scan->data;

		if (g_strcmp0 (gth_transition_get_id (transition), current_transition) == 0)
			i_active = i;

		gtk_list_store_append (model, &iter);
		gtk_list_store_set (model, &iter,
				    TRANSITION_COLUMN_ID, gth_transition_get_id (transition),
				    TRANSITION_COLUMN_DISPLAY_NAME, gth_transition_get_display_name (transition),
				    -1);
	}

	if (g_strcmp0 ("random", current_transition) == 0)
		i_active = i;
	gtk_list_store_append (model, &iter);
	gtk_list_store_set (model, &iter,
			    TRANSITION_COLUMN_ID, "random",
			    TRANSITION_COLUMN_DISPLAY_NAME, _("Random"),
			    -1);

	gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->transition_combobox), i_active);
	gtk_widget_show (self->priv->transition_combobox);
	gtk_box_pack_start (GTK_BOX (_gtk_builder_get_widget (self->priv->builder, "transition_box")), self->priv->transition_combobox, FALSE, FALSE, 0);

	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (_gtk_builder_get_widget (self->priv->builder, "automatic_checkbutton")), automatic);
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (_gtk_builder_get_widget (self->priv->builder, "change_delay_spinbutton")), ((float) delay) / 1000.0);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (_gtk_builder_get_widget (self->priv->builder, "wrap_around_checkbutton")), wrap_around);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (_gtk_builder_get_widget (self->priv->builder, "random_order_checkbutton")), random_order);

	/* signals */

	g_signal_connect (_gtk_builder_get_widget (self->priv->builder, "personalize_checkbutton"),
			  "toggled",
			  G_CALLBACK (personalize_checkbutton_toggled_cb),
			  self);
	g_signal_connect (_gtk_builder_get_widget (self->priv->builder, "automatic_checkbutton"),
			  "toggled",
			  G_CALLBACK (automatic_checkbutton_toggled_cb),
			  self);
	g_signal_connect (_gtk_builder_get_widget (self->priv->builder, "remove_file_button"),
			  "clicked",
			  G_CALLBACK (remove_file_button_clicked_cb),
			  self);
	g_signal_connect (_gtk_builder_get_widget (self->priv->builder, "add_file_button"),
			  "clicked",
			  G_CALLBACK (add_file_button_clicked_cb),
			  self);
}
Esempio n. 17
0
static void
_dtv_init (DiagramTreeView *dtv)
{
  GtkTreeViewColumn *column;
  GtkCellRenderer   *cell;
  gint               font_size;
  GtkStyle          *style;

  /* connect the model with the view */
  gtk_tree_view_set_model (GTK_TREE_VIEW (dtv), diagram_tree_model_new ());

  gtk_tree_view_set_fixed_height_mode (GTK_TREE_VIEW (dtv), TRUE);
  /* the tree requires reading across rows (semantic hint) */
#if 0 /* stripe style */
  gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (dtv), TRUE);
#endif

  style = gtk_widget_get_style (GTK_WIDGET (dtv));
  font_size = pango_font_description_get_size (style->font_desc);
  font_size = PANGO_PIXELS (font_size);

  /* first colum: name of diagram/layer/object - here is the tree */
  cell = gtk_cell_renderer_text_new ();
  gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (cell), 1);
  g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);

  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column, _("Name"));
  gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
  gtk_tree_view_column_set_min_width (column, font_size * 10);
  gtk_tree_view_column_set_expand (column, TRUE);
  gtk_tree_view_column_set_resizable (column, TRUE);
  
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), cell, TRUE);
  gtk_tree_view_column_add_attribute (column, cell, "text", NAME_COLUMN);
  gtk_tree_view_insert_column (GTK_TREE_VIEW (dtv), column, -1);

  /* this is enough for simple name search (just typing) */
  gtk_tree_view_set_search_column (GTK_TREE_VIEW (dtv), NAME_COLUMN);
  /* must have a sortable model ... */
  gtk_tree_view_column_set_sort_column_id (column, NAME_COLUMN);

  /* type column - show the type icon */
  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column, _("Type"));
  /* must have fixed size, too */
  gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
  /* without it gets zero size - not very useful! */
  gtk_tree_view_column_set_min_width (column, font_size * 6);
  gtk_tree_view_column_set_resizable (column, TRUE);
  cell = gtk_cell_renderer_pixbuf_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), cell, TRUE);
  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), cell,
				      _dtv_cell_pixbuf_func, dtv, NULL);
  gtk_tree_view_insert_column (GTK_TREE_VIEW (dtv), column, -1);
  gtk_tree_view_column_set_sort_column_id (column, OBJECT_COLUMN);

  /*  TODO: other fancy stuff */

  {
    GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dtv));

    gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
    gtk_tree_view_set_rubber_banding (GTK_TREE_VIEW (dtv), TRUE);
  }
  gtk_widget_set_has_tooltip (GTK_WIDGET (dtv), TRUE);


  _dtv_create_popup_menu (dtv);
}
Esempio n. 18
0
/* Main UI */
GtkWidget *
pgd_annots_create_widget (PopplerDocument *document)
{
    PgdAnnotsDemo    *demo;
    GtkWidget        *label;
    GtkWidget        *vbox, *vbox2;
    GtkWidget        *button;
    GtkWidget        *hbox, *page_selector;
    GtkWidget        *hpaned;
    GtkWidget        *swindow, *treeview;
    GtkTreeSelection *selection;
    GtkCellRenderer  *renderer;
    GtkTreeViewColumn *column;
    GtkListStore     *model;
    GtkTreeIter       iter;
    gchar            *str;
    gint              n_pages;
    gint              i;

    demo = g_new0 (PgdAnnotsDemo, 1);

    demo->doc = g_object_ref (document);
    demo->cursor = GDK_LAST_CURSOR;
    demo->mode = MODE_NORMAL;

    n_pages = poppler_document_get_n_pages (document);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
    vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);

    label = gtk_label_new ("Page:");
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
    gtk_widget_show (label);

    page_selector = gtk_spin_button_new_with_range (1, n_pages, 1);
    g_signal_connect (G_OBJECT (page_selector), "value-changed",
                      G_CALLBACK (pgd_annots_page_selector_value_changed),
                      (gpointer) demo);
    gtk_box_pack_start (GTK_BOX (hbox), page_selector, FALSE, TRUE, 0);
    gtk_widget_show (page_selector);

    str = g_strdup_printf ("of %d", n_pages);
    label = gtk_label_new (str);
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
    gtk_widget_show (label);
    g_free (str);

    demo->remove_button = gtk_button_new_with_mnemonic ("_Remove");
    gtk_widget_set_sensitive (demo->remove_button, FALSE);
    g_signal_connect (G_OBJECT (demo->remove_button), "clicked",
                      G_CALLBACK (pgd_annots_remove_annot),
                      (gpointer) demo);
    gtk_box_pack_end (GTK_BOX (hbox), demo->remove_button, FALSE, FALSE, 6);
    gtk_widget_show (demo->remove_button);

    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);

    button = gtk_button_new_with_mnemonic ("_Add");
    g_signal_connect (G_OBJECT (button), "clicked",
                      G_CALLBACK (pgd_annots_start_add_annot),
                      (gpointer) demo);
    gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
    gtk_widget_show (button);

    model = gtk_list_store_new(SELECTED_N_COLUMNS,
                               G_TYPE_INT, G_TYPE_STRING);

    for (i = 0; i < G_N_ELEMENTS (supported_annots); i++) {
        gtk_list_store_append (model, &iter);
        gtk_list_store_set (model, &iter,
                            SELECTED_TYPE_COLUMN, supported_annots[i].type,
                            SELECTED_LABEL_COLUMN, supported_annots[i].label,
                            -1);
    }

    demo->type_selector = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model));
    g_object_unref (model);

    renderer = gtk_cell_renderer_text_new ();
    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (demo->type_selector), renderer, TRUE);
    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (demo->type_selector), renderer,
                                    "text", SELECTED_LABEL_COLUMN,
                                    NULL);
    gtk_combo_box_set_active (GTK_COMBO_BOX (demo->type_selector), 0);
    gtk_box_pack_end (GTK_BOX (hbox), demo->type_selector, FALSE, FALSE, 0);
    gtk_widget_show (demo->type_selector);

    button = gtk_color_button_new ();
    demo->annot_color.red = 65535;
    demo->annot_color.alpha = 1.0;
    gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), &demo->annot_color);
    g_signal_connect (button, "notify::color",
                      G_CALLBACK (pgd_annot_color_changed),
                      (gpointer)demo);
    gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, TRUE, 0);
    gtk_widget_show (button);

    gtk_widget_show (hbox);

    demo->timer_label = gtk_label_new (NULL);
    gtk_label_set_markup (GTK_LABEL (demo->timer_label), "<i>No annotations found</i>");
    g_object_set (G_OBJECT (demo->timer_label), "xalign", 1.0, NULL);
    gtk_box_pack_start (GTK_BOX (vbox), demo->timer_label, FALSE, TRUE, 0);
    gtk_widget_show (demo->timer_label);

    hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);

    demo->annot_view = pgd_annot_view_new ();

    swindow = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);

    demo->model = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING,
                                      GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN,
				      G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
				      G_TYPE_OBJECT);
    treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (demo->model));
    demo->tree_view = treeview;

    column = gtk_tree_view_column_new ();
    gtk_tree_view_column_set_title (column, "Type");
    gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);

    renderer = gtk_cell_renderer_pixbuf_new ();
    gtk_tree_view_column_pack_start (column, renderer, TRUE);
    gtk_tree_view_column_add_attribute (column, renderer, "pixbuf", ANNOTS_COLOR_COLUMN);

    renderer = gtk_cell_renderer_text_new ();
    gtk_tree_view_column_pack_start (column, renderer, TRUE);
    gtk_tree_view_column_add_attribute (column, renderer, "text", ANNOTS_TYPE_COLUMN);

    renderer = gtk_cell_renderer_toggle_new ();
    g_signal_connect (renderer, "toggled",
		      G_CALLBACK (pgd_annots_invisible_flag_toggled),
		      (gpointer) demo);
    gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
                                                 ANNOTS_FLAG_INVISIBLE_COLUMN, "Invisible",
                                                 renderer,
                                                 "active", ANNOTS_FLAG_INVISIBLE_COLUMN,
                                                 NULL);

    renderer = gtk_cell_renderer_toggle_new ();
    g_signal_connect (renderer, "toggled",
                      G_CALLBACK (pgd_annots_hidden_flag_toggled),
                      (gpointer) demo);
    gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
                                                 ANNOTS_FLAG_HIDDEN_COLUMN, "Hidden",
                                                 renderer,
                                                 "active", ANNOTS_FLAG_HIDDEN_COLUMN,
                                                 NULL);

    renderer = gtk_cell_renderer_toggle_new ();
    g_signal_connect (renderer, "toggled",
                      G_CALLBACK (pgd_annots_print_flag_toggled),
                      (gpointer) demo);
    gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
                                                 ANNOTS_FLAG_PRINT_COLUMN, "Print",
                                                 renderer,
                                                 "active", ANNOTS_FLAG_PRINT_COLUMN,
                                                 NULL);

    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
    g_signal_connect (G_OBJECT (selection), "changed",
                      G_CALLBACK (pgd_annots_selection_changed),
                      (gpointer) demo);

    /* Annotation's list */
    gtk_container_add (GTK_CONTAINER (swindow), treeview);
    gtk_widget_show (treeview);

    gtk_box_pack_start (GTK_BOX (vbox2), swindow, TRUE, TRUE, 0);
    gtk_widget_show (swindow);

    /* Annotation Properties */
    swindow = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);
    gtk_container_add (GTK_CONTAINER (swindow), demo->annot_view);
    gtk_widget_show (demo->annot_view);
    gtk_widget_show (swindow);

    gtk_box_pack_start (GTK_BOX (vbox2), swindow, TRUE, TRUE, 6);
    gtk_widget_show (swindow);

    gtk_paned_add1 (GTK_PANED (hpaned), vbox2);
    gtk_widget_show (vbox2);

    /* Demo Area (Render) */
    demo->darea = gtk_drawing_area_new ();
    g_signal_connect (demo->darea, "draw",
                      G_CALLBACK (pgd_annots_view_drawing_area_draw),
                      demo);
    g_signal_connect (demo->darea, "realize",
                      G_CALLBACK (pgd_annots_drawing_area_realize),
                      (gpointer)demo);
    g_signal_connect (demo->darea, "button_press_event",
                      G_CALLBACK (pgd_annots_drawing_area_button_press),
                      (gpointer)demo);
    g_signal_connect (demo->darea, "motion_notify_event",
                      G_CALLBACK (pgd_annots_drawing_area_motion_notify),
                      (gpointer)demo);
    g_signal_connect (demo->darea, "button_release_event",
                      G_CALLBACK (pgd_annots_drawing_area_button_release),
                      (gpointer)demo);

    swindow = gtk_scrolled_window_new (NULL, NULL);
#if GTK_CHECK_VERSION(3, 7, 8)
    gtk_container_add(GTK_CONTAINER(swindow), demo->darea);
#else
    gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (swindow), demo->darea);
#endif
    gtk_widget_show (demo->darea);

    gtk_paned_add2 (GTK_PANED (hpaned), swindow);
    gtk_widget_show (swindow);

    gtk_paned_set_position (GTK_PANED (hpaned), 300);

    gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
    gtk_widget_show (hpaned);

    g_object_weak_ref (G_OBJECT (vbox),
                       (GWeakNotify)pgd_annots_free,
                       demo);

    pgd_annots_viewer_queue_redraw (demo);
    pgd_annots_get_annots (demo);

    demo->main_box = vbox;

    return vbox;
}
Esempio n. 19
0
GtkWidget* file_properties_dlg_new( GtkWindow* parent,
                                    const char* dir_path,
                                    GList* sel_files, int page )
{
    GtkBuilder* builder = _gtk_builder_new_from_file( PACKAGE_UI_DIR "/file_properties.ui", NULL );

    GtkWidget * dlg = (GtkWidget*)gtk_builder_get_object( builder, "dlg" );
    GtkNotebook* notebook = (GtkNotebook*)gtk_builder_get_object( builder, "notebook" );
    xset_set_window_icon( GTK_WINDOW( dlg ) );

    FilePropertiesDialogData* data;
    gboolean need_calc_size = TRUE;

    VFSFileInfo *file, *file2;
    VFSMimeType* mime;

    const char* multiple_files = _( "( multiple files )" );
    const char* calculating;
    GtkWidget* name = (GtkWidget*)gtk_builder_get_object( builder, "file_name" );
    GtkWidget* label_name = (GtkWidget*)gtk_builder_get_object( builder, "label_filename" );
    GtkWidget* location = (GtkWidget*)gtk_builder_get_object( builder, "location" );
    gtk_editable_set_editable ( GTK_EDITABLE( location ), FALSE );
    GtkWidget* target = (GtkWidget*)gtk_builder_get_object( builder, "target" );
    GtkWidget* label_target = (GtkWidget*)gtk_builder_get_object( builder, "label_target" );
    gtk_editable_set_editable ( GTK_EDITABLE( target ), FALSE );
    GtkWidget* mime_type = (GtkWidget*)gtk_builder_get_object( builder, "mime_type" );
    GtkWidget* open_with = (GtkWidget*)gtk_builder_get_object( builder, "open_with" );

    char buf[ 64 ];
    char buf2[ 32 ];
    const char* time_format = "%Y-%m-%d %H:%M:%S";

    gchar* disp_path;
    gchar* file_type;

    int i;
    GList* l;
    gboolean same_type = TRUE;
    gboolean is_dirs = FALSE;
    char *owner_group, *tmp;

    gtk_dialog_set_alternative_button_order( GTK_DIALOG(dlg), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1 );
    ptk_dialog_fit_small_screen( GTK_DIALOG(dlg) );

    int width = xset_get_int( "app_dlg", "s" );
    int height = xset_get_int( "app_dlg", "z" );
    if ( width && height )
        gtk_window_set_default_size( GTK_WINDOW( dlg ), width, -1 );

    data = g_slice_new0( FilePropertiesDialogData );
    /* FIXME: When will the data be freed??? */
    g_object_set_data( G_OBJECT( dlg ), "DialogData", data );
    data->file_list = sel_files;
    data->dlg = dlg;

    data->dir_path = g_strdup( dir_path );
    disp_path = g_filename_display_name( dir_path );
    //gtk_label_set_text( GTK_LABEL( location ), disp_path );
    gtk_entry_set_text( GTK_ENTRY( location ), disp_path );
    g_free( disp_path );

    data->total_size_label = GTK_LABEL( (GtkWidget*)gtk_builder_get_object( builder, "total_size" ) );
    data->size_on_disk_label = GTK_LABEL( (GtkWidget*)gtk_builder_get_object( builder, "size_on_disk" ) );
    data->count_label = GTK_LABEL( (GtkWidget*)gtk_builder_get_object( builder, "count" ) );
    data->owner = GTK_ENTRY( (GtkWidget*)gtk_builder_get_object( builder, "owner" ) );
    data->group = GTK_ENTRY( (GtkWidget*)gtk_builder_get_object( builder, "group" ) );
    data->mtime = GTK_ENTRY( (GtkWidget*)gtk_builder_get_object( builder, "mtime" ) );
    data->atime = GTK_ENTRY( (GtkWidget*)gtk_builder_get_object( builder, "atime" ) );

    for ( i = 0; i < N_CHMOD_ACTIONS; ++i )
    {
        data->chmod_btns[ i ] = GTK_TOGGLE_BUTTON( (GtkWidget*)gtk_builder_get_object( builder, chmod_names[ i ] ) );
    }

    //MOD
    VFSMimeType* type; 
    VFSMimeType* type2 = NULL;
    for ( l = sel_files; l ; l = l->next )
    {
        file = ( VFSFileInfo* ) l->data;
        type = vfs_file_info_get_mime_type( file );
        if ( !type2 )
            type2 = vfs_file_info_get_mime_type( file );
        if ( vfs_file_info_is_dir( file ) )
            is_dirs = TRUE;
        if ( type != type2 )
            same_type = FALSE;
        vfs_mime_type_unref( type );
        if ( is_dirs && !same_type )
            break;
    }
    if ( type2 )
        vfs_mime_type_unref( type2 );

    data->recurse = (GtkWidget*)gtk_builder_get_object( builder, "recursive" );
    gtk_widget_set_sensitive( data->recurse, is_dirs );

/*  //MOD
    for ( l = sel_files; l && l->next; l = l->next )
    {
        VFSMimeType *type, *type2;
        file = ( VFSFileInfo* ) l->data;
        file2 = ( VFSFileInfo* ) l->next->data;
        type = vfs_file_info_get_mime_type( file );
        type2 = vfs_file_info_get_mime_type( file2 );
        if ( type != type2 )
        {
            vfs_mime_type_unref( type );
            vfs_mime_type_unref( type2 );
            same_type = FALSE;
            break;
        }
        vfs_mime_type_unref( type );
        vfs_mime_type_unref( type2 );
    }
*/

    file = ( VFSFileInfo* ) sel_files->data;
    if ( same_type )
    {
        mime = vfs_file_info_get_mime_type( file );
        file_type = g_strdup_printf( "%s\n%s",
                                     vfs_mime_type_get_description( mime ),
                                     vfs_mime_type_get_type( mime ) );
        gtk_label_set_text( GTK_LABEL( mime_type ), file_type );
        g_free( file_type );
        vfs_mime_type_unref( mime );
    }
    else
    {
        gtk_label_set_text( GTK_LABEL( mime_type ), _( "( multiple types )" ) );
    }

    /* Open with...
     * Don't show this option menu if files of different types are selected,
     * ,the selected file is a folder, or its type is unknown.
     */
    if( ! same_type ||
          vfs_file_info_is_desktop_entry( file ) ||
        /*  vfs_file_info_is_unknown_type( file ) || */
          vfs_file_info_is_executable( file, NULL ) )
    {
        /* if open with shouldn't show, destroy it. */
        gtk_widget_destroy( open_with );
        open_with = NULL;
        gtk_widget_destroy( (GtkWidget*)gtk_builder_get_object( builder, "open_with_label" ) );
    }
    else /* Add available actions to the option menu */
    {
        GtkTreeIter it;
        char **action, **actions;

        mime = vfs_file_info_get_mime_type( file );
        actions = vfs_mime_type_get_actions( mime );
        GtkCellRenderer* renderer;
        GtkListStore* model;
        gtk_cell_layout_clear( GTK_CELL_LAYOUT(open_with) );
        renderer = gtk_cell_renderer_pixbuf_new();
        gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(open_with), renderer, FALSE);
        gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT(open_with), renderer,
                                        "pixbuf", 0, NULL );
        renderer = gtk_cell_renderer_text_new();
        gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(open_with), renderer, TRUE);
        gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT(open_with),renderer,
                                        "text", 1, NULL );
        model = gtk_list_store_new( 3, GDK_TYPE_PIXBUF,
                                    G_TYPE_STRING,
                                    G_TYPE_STRING,
                                    G_TYPE_STRING );
        if( actions )
        {
            for( action = actions; *action; ++action )
            {
                VFSAppDesktop* desktop;
                GdkPixbuf* icon;
                desktop = vfs_app_desktop_new( *action );
                gtk_list_store_append( model, &it );
                icon = vfs_app_desktop_get_icon(desktop, 20, TRUE);
                gtk_list_store_set( model, &it,
                                    0, icon,
                                    1, vfs_app_desktop_get_disp_name(desktop),
                                    2, *action, -1 );
                if( icon )
                    g_object_unref( icon );
                vfs_app_desktop_unref( desktop );
            }
        }
        else
        {
            g_object_set_data( G_OBJECT(open_with), "prev_sel", GINT_TO_POINTER(-1) );
        }

        /* separator */
        gtk_list_store_append( model, &it );

        gtk_list_store_append( model, &it );
        gtk_list_store_set( model, &it,
                            0, NULL,
                            1, _("Choose..."), -1 );
        gtk_combo_box_set_model( GTK_COMBO_BOX(open_with),
                                 GTK_TREE_MODEL(model) );
        gtk_combo_box_set_row_separator_func(
                GTK_COMBO_BOX(open_with), combo_sep,
                NULL, NULL );
        gtk_combo_box_set_active(GTK_COMBO_BOX(open_with), 0);
        g_signal_connect( open_with, "changed",
                          G_CALLBACK(on_combo_change), mime );

        /* vfs_mime_type_unref( mime ); */
        /* We can unref mime when combo box gets destroyed */
        g_object_weak_ref( G_OBJECT(open_with),
                           (GWeakNotify)vfs_mime_type_unref, mime );
    }
    g_object_set_data( G_OBJECT(dlg), "open_with", open_with );

    /* Multiple files are selected */
    if ( sel_files && sel_files->next )
    {
        gtk_widget_set_sensitive( name, FALSE );
        gtk_entry_set_text( GTK_ENTRY( name ), multiple_files );

        data->orig_mtime = NULL;
        data->orig_atime = NULL;
        
        for ( i = 0; i < N_CHMOD_ACTIONS; ++i )
        {
            gtk_toggle_button_set_inconsistent ( data->chmod_btns[ i ], TRUE );
            data->chmod_states[ i ] = 2; /* Don't touch this bit */
            g_signal_connect( G_OBJECT( data->chmod_btns[ i ] ), "toggled",
                              G_CALLBACK( on_chmod_btn_toggled ), data );
        }
    }
    else
    {
        /* special processing for files with special display names */
        if( vfs_file_info_is_desktop_entry( file ) )
        {
            char* disp_name = g_filename_display_name( file->name );
            gtk_entry_set_text( GTK_ENTRY( name ),
                                disp_name );
            g_free( disp_name );
        }
        else
        {
            if ( vfs_file_info_is_dir( file ) && 
                                            !vfs_file_info_is_symlink( file ) )
                gtk_label_set_markup_with_mnemonic( GTK_LABEL( label_name ),
                                                    _("<b>Folder _Name:</b>") );
            gtk_entry_set_text( GTK_ENTRY( name ),
                                vfs_file_info_get_disp_name( file ) );
        }
        
        gtk_editable_set_editable ( GTK_EDITABLE( name ), FALSE );

        if ( ! vfs_file_info_is_dir( file ) )
        {
            /* Only single "file" is selected, so we don't need to
                caculate total file size */
            need_calc_size = FALSE;

            sprintf( buf, _("%s  ( %lu bytes )"),
                     vfs_file_info_get_disp_size( file ),
                     ( guint64 ) vfs_file_info_get_size( file ) );
            gtk_label_set_text( data->total_size_label, buf );

            vfs_file_size_to_string( buf2,
                                 vfs_file_info_get_blocks( file ) * 512 );
            sprintf( buf, _("%s  ( %lu bytes )"), buf2,
                     ( guint64 ) vfs_file_info_get_blocks( file ) * 512 );
            gtk_label_set_text( data->size_on_disk_label, buf );
            
            gtk_label_set_text( data->count_label, _("1 file") );
        }
        
        // Modified / Accessed
        //gtk_entry_set_text( GTK_ENTRY( mtime ),
        //                    vfs_file_info_get_disp_mtime( file ) );
        strftime( buf, sizeof( buf ),
                  time_format, localtime( vfs_file_info_get_mtime( file ) ) );
        gtk_entry_set_text( GTK_ENTRY( data->mtime ), buf );
        data->orig_mtime = g_strdup( buf );

        strftime( buf, sizeof( buf ),
                  time_format, localtime( vfs_file_info_get_atime( file ) ) );
        gtk_entry_set_text( GTK_ENTRY( data->atime ), buf );
        data->orig_atime = g_strdup( buf );

        // Permissions
        owner_group = (char *) vfs_file_info_get_disp_owner( file );
        tmp = strchr( owner_group, ':' );
        data->owner_name = g_strndup( owner_group, tmp - owner_group );
        gtk_entry_set_text( GTK_ENTRY( data->owner ), data->owner_name );
        data->group_name = g_strdup( tmp + 1 );
        gtk_entry_set_text( GTK_ENTRY( data->group ), data->group_name );

        for ( i = 0; i < N_CHMOD_ACTIONS; ++i )
        {
            if ( data->chmod_states[ i ] != 2 ) /* allow to touch this bit */
            {
                data->chmod_states[ i ] = ( vfs_file_info_get_mode( file ) & chmod_flags[ i ] ? 1 : 0 );
                gtk_toggle_button_set_active( data->chmod_btns[ i ], data->chmod_states[ i ] );
            }
        }
        
        // target
        if ( vfs_file_info_is_symlink( file ) )
        {
            gtk_label_set_markup_with_mnemonic( GTK_LABEL( label_name ),
                                                    _("<b>Link _Name:</b>") );
            disp_path = g_build_filename( dir_path, file->name, NULL );
            char* target_path = g_file_read_link( disp_path, NULL );
            if ( target_path )
            {
                gtk_entry_set_text( GTK_ENTRY( target ), target_path );
                if ( target_path[0] && target_path[0] != '/' )
                {
                    // relative link to absolute
                    char* str = target_path;
                    target_path = g_build_filename( dir_path, str, NULL );
                    g_free( str );
                }
                if ( !g_file_test( target_path, G_FILE_TEST_EXISTS ) )
                    gtk_label_set_text( GTK_LABEL( mime_type ),
                                                    _("( broken link )") );
                g_free( target_path );
            }
            else
                gtk_entry_set_text( GTK_ENTRY( target ), _("( read link error )") );
            g_free( disp_path );
            gtk_widget_show( target );
            gtk_widget_show( label_target );
        }
    }

    if ( need_calc_size )
    {
        /* The total file size displayed in "File Properties" is not
           completely calculated yet. So "Calculating..." is displayed. */
        calculating = _( "Calculating..." );
        gtk_label_set_text( data->total_size_label, calculating );
        gtk_label_set_text( data->size_on_disk_label, calculating );

        g_object_set_data( G_OBJECT( dlg ), "calc_size", data );
        data->calc_size_thread = g_thread_create ( ( GThreadFunc ) calc_size,
                                                   data, TRUE, NULL );
        data->update_label_timer = g_timeout_add( 250,
                                                  ( GSourceFunc ) on_update_labels,
                                                  data );
    }

    g_signal_connect( dlg, "response",
                        G_CALLBACK(on_dlg_response), dlg );
    g_signal_connect_swapped( gtk_builder_get_object(builder, "ok_button"),
                        "clicked",
                        G_CALLBACK(gtk_widget_destroy), dlg );
    g_signal_connect_swapped( gtk_builder_get_object(builder, "cancel_button"),
                        "clicked",
                        G_CALLBACK(gtk_widget_destroy), dlg );
    
    g_object_unref( builder );

    gtk_notebook_set_current_page( notebook, page );

    gtk_window_set_transient_for( GTK_WINDOW( dlg ), parent );
    return dlg;
}
Esempio n. 20
0
/*!
 *\brief	Create the matcher dialog
 */
static void prefs_filtering_action_create(void)
{
	GtkWidget *window;
	GtkWidget *vbox;
	GtkWidget *ok_btn;
	GtkWidget *cancel_btn;
	GtkWidget *confirm_area;

	GtkWidget *vbox1;
	GtkWidget *frame;
	GtkWidget *table;
	GtkWidget *hbox1;

	GtkWidget *label1;
	GtkWidget *label2;
	GtkWidget *label3;
	GtkWidget *action_combo;
	GtkWidget *account_combo;
	GtkWidget *header_combo;
	GtkWidget *header_entry;
#ifndef USE_ALT_ADDRBOOK
	GtkWidget *addressbook_btn;
#endif
	GtkWidget *dest_entry;
	GtkWidget *dest_btn;
	GtkWidget *score_entry;
	GtkWidget *tags_combo;

	GtkWidget *reg_hbox;
	GtkWidget *btn_hbox;
	GtkWidget *arrow;
	GtkWidget *reg_btn;
	GtkWidget *subst_btn;
	GtkWidget *del_btn;

	GtkWidget *action_hbox;
	GtkWidget *action_scrolledwin;
	GtkWidget *action_list_view;

	GtkWidget *btn_vbox;
	GtkWidget *up_btn;
	GtkWidget *down_btn;

	GtkWidget *exec_btn;

#if !GTK_CHECK_VERSION(3, 0, 0)
	GtkWidget *color_optmenu;
#endif

	static GdkGeometry geometry;

        GList * accounts;
	GSList *tmp, *tags;

	GtkSizeGroup *size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
	GtkSizeGroup *size_action = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
	GtkTreeModel *model;
	GtkCellRenderer *renderer;

	debug_print("Creating matcher configuration window...\n");

	window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_filtering_action");
	gtk_container_set_border_width(GTK_CONTAINER(window), VBOX_BORDER);
	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_window_set_resizable(GTK_WINDOW(window), TRUE);

	vbox = gtk_vbox_new(FALSE, 6);
	gtk_container_add(GTK_CONTAINER(window), vbox);

	gtkut_stock_button_set_create(&confirm_area,
				      &cancel_btn, GTK_STOCK_CANCEL,
				      &ok_btn, GTK_STOCK_OK,
				      NULL, NULL);
	gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
	gtk_widget_grab_default(ok_btn);

	gtk_window_set_title(GTK_WINDOW(window),
			     _("Action configuration"));
	g_signal_connect(G_OBJECT(window), "delete_event",
			 G_CALLBACK(prefs_filtering_action_deleted), NULL);
	g_signal_connect(G_OBJECT(window), "size_allocate",
			 G_CALLBACK(prefs_filtering_action_size_allocate_cb), NULL);
	g_signal_connect(G_OBJECT(window), "key_press_event",
			 G_CALLBACK(prefs_filtering_action_key_pressed), NULL);
	MANAGE_WINDOW_SIGNALS_CONNECT(window);
	g_signal_connect(G_OBJECT(ok_btn), "clicked",
			 G_CALLBACK(prefs_filtering_action_ok), NULL);
	g_signal_connect(G_OBJECT(cancel_btn), "clicked",
			 G_CALLBACK(prefs_filtering_action_cancel), NULL);

	vbox1 = gtk_vbox_new(FALSE, VSPACING);
	gtk_box_pack_start(GTK_BOX(vbox), vbox1, TRUE, TRUE, 0);
	gtk_container_set_border_width(GTK_CONTAINER (vbox1), 2);

	frame = gtk_frame_new(_("Rule"));
	gtk_frame_set_label_align(GTK_FRAME(frame), 0.01, 0.5);
	gtk_box_pack_start (GTK_BOX (vbox1), frame, FALSE, FALSE, 0);	
	gtk_widget_set_size_request(frame, -1, 110);
	
	table = gtk_table_new(3, 3, FALSE);
	gtk_container_set_border_width(GTK_CONTAINER(table), 2);
	gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
	gtk_table_set_col_spacings (GTK_TABLE (table), HSPACING_NARROW);
        gtk_container_add(GTK_CONTAINER(frame), table);
        
        /* first row labels */

	label1 = gtk_label_new (_("Action"));
	gtk_widget_set_size_request(label1, LABELS_WIDTH, -1);
	gtk_size_group_add_widget(size_group, label1);
	gtk_misc_set_alignment (GTK_MISC (label1), 1, 0.5);
	gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1, 
			GTK_FILL, GTK_SHRINK, 0, 0);

	label2 = gtk_label_new ("");
	gtk_size_group_add_widget(size_group, label2);
	gtk_misc_set_alignment (GTK_MISC (label2), 1, 0.5);
	gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2, 
			GTK_FILL, GTK_SHRINK, 0, 0);

	label3 = gtk_label_new ("");
	gtk_size_group_add_widget(size_group, label3);
	gtk_misc_set_alignment (GTK_MISC (label3), 1, 0.5);
	gtk_table_attach(GTK_TABLE(table), label3, 0, 1, 2, 3, 
			GTK_FILL, GTK_SHRINK, 0, 0);

	/* action combo */
	
	hbox1 = gtk_hbox_new(FALSE, 0);
	gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 0, 1, 
			GTK_FILL, GTK_SHRINK, 0, 0);
			
	model = prefs_filtering_action_create_model();
	action_combo = gtk_combo_box_new_with_model(model);
	gtk_size_group_add_widget(size_action, action_combo);

	renderer = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(action_combo), renderer, TRUE);
        gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(action_combo), renderer,
				       "text", ACTION_COMBO_TEXT,
				       "sensitive", ACTION_COMBO_SENS,
				       NULL);
	gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(action_combo), renderer,
					   cell_is_sensitive, NULL, NULL);

	combobox_select_by_data(GTK_COMBO_BOX(action_combo), ACTION_MOVE);
	g_signal_connect(G_OBJECT(action_combo), "changed",
			 G_CALLBACK(prefs_filtering_action_type_selection_changed),
			 NULL);
	gtk_box_pack_start(GTK_BOX(hbox1), action_combo, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox1), gtk_label_new(""), TRUE, TRUE, 0);

	/* accounts */

	hbox1 = gtk_hbox_new (FALSE, 0);
	gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 1, 2, 
			 GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);

#if !GTK_CHECK_VERSION(2, 24, 0)
	account_combo = gtk_combo_box_new_text ();
#else
	account_combo = gtk_combo_box_text_new ();
#endif
	gtk_size_group_add_widget(size_action, account_combo);

	for (accounts = account_get_list() ; accounts != NULL;
	     accounts = accounts->next) {
		PrefsAccount *ac = (PrefsAccount *)accounts->data;
		gchar *name = g_strdup(ac->account_name);
#if !GTK_CHECK_VERSION(2, 24, 0)
		gtk_combo_box_append_text(GTK_COMBO_BOX(account_combo), (gpointer) name);
#else
		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(account_combo), (gpointer) name);
#endif
		g_free(name);
	}

	prefs_filtering_action_check_widget_width(account_combo);
	gtk_combo_box_set_active(GTK_COMBO_BOX(account_combo), 0);
	gtk_box_pack_start (GTK_BOX (hbox1), account_combo,
			    FALSE, FALSE, 0);

	/* header */

	header_combo = combobox_text_new(TRUE, "From", "To", "Cc", "Reply-To", "Sender", NULL);
	gtk_size_group_add_widget(size_action, header_combo);
	gtk_box_pack_start (GTK_BOX (hbox1), header_combo,
			    FALSE, FALSE, 0);
	header_entry = gtk_bin_get_child(GTK_BIN((header_combo)));

	/* destination */

	hbox1 = gtk_hbox_new (FALSE, 0);
	gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 2, 3, 
			GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);

	dest_entry = gtk_entry_new ();
	gtk_box_pack_start (GTK_BOX (hbox1), dest_entry, TRUE, TRUE, 0);
	
	score_entry = gtk_spin_button_new_with_range(-1000, 1000, 1);
	gtk_box_pack_start(GTK_BOX(hbox1), score_entry, FALSE, FALSE, 0);
	
#if !GTK_CHECK_VERSION(3, 0, 0)
	color_optmenu = gtk_cmoption_menu_new();
	gtk_size_group_add_widget(size_action, color_optmenu);
	gtk_cmoption_menu_set_menu(GTK_CMOPTION_MENU(color_optmenu),
				 colorlabel_create_color_menu());
	prefs_filtering_action_check_widget_width(color_optmenu);
	gtk_box_pack_start(GTK_BOX(hbox1), color_optmenu, FALSE, FALSE, 0);
#endif

#if !GTK_CHECK_VERSION(2, 24, 0)
	tags_combo = gtk_combo_box_new_text ();
#else
	tags_combo = gtk_combo_box_text_new ();
#endif
	gtk_size_group_add_widget(size_action, tags_combo);

	for (tmp = tags = tags_get_list() ; tmp != NULL;
	     tmp = tmp->next) {
		gchar *name = g_strdup(tags_get_tag(GPOINTER_TO_INT(tmp->data)));

#if !GTK_CHECK_VERSION(2, 24, 0)
		gtk_combo_box_append_text(GTK_COMBO_BOX(tags_combo), (gpointer) name);
#else
		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(tags_combo), (gpointer) name);
#endif
		g_free(name);
	}
	g_slist_free(tags);

	prefs_filtering_action_check_widget_width(tags_combo);
	gtk_combo_box_set_active(GTK_COMBO_BOX(tags_combo), 0);
	gtk_box_pack_start (GTK_BOX (hbox1), tags_combo,
			    FALSE, FALSE, 0);

	hbox1 = gtk_hbox_new (FALSE, 0);
	gtk_table_attach(GTK_TABLE(table), hbox1, 2, 3, 2, 3, 
			GTK_FILL, GTK_SHRINK, 0, 0);

	dest_btn = gtk_button_new_with_label (_("Select..."));
	gtk_box_pack_start (GTK_BOX (hbox1), dest_btn, FALSE, FALSE, 0);
	g_signal_connect (G_OBJECT (dest_btn), "clicked",
			  G_CALLBACK(prefs_filtering_action_select_dest),
			  NULL);

#ifndef USE_ALT_ADDRBOOK
	addressbook_btn = gtk_button_new_with_label (_("Select..."));
	gtk_box_pack_start (GTK_BOX (hbox1), addressbook_btn, FALSE, FALSE, 0);
	g_signal_connect (G_OBJECT (addressbook_btn), "clicked",
			  G_CALLBACK(prefs_filtering_action_select_addressbook),
			  NULL);
#endif

	exec_btn = gtk_button_new_from_stock(GTK_STOCK_INFO);
	gtk_box_pack_start (GTK_BOX (hbox1), exec_btn, FALSE, FALSE, 0);
	g_signal_connect (G_OBJECT (exec_btn), "clicked",
			  G_CALLBACK(prefs_filtering_action_exec_info),
			  window);

	/* register / substitute / delete */

	reg_hbox = gtk_hbox_new(FALSE, 4);
	gtk_box_pack_start(GTK_BOX(vbox1), reg_hbox, FALSE, FALSE, 0);

	arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
	gtk_box_pack_start(GTK_BOX(reg_hbox), arrow, FALSE, FALSE, 0);
	gtk_widget_set_size_request(arrow, -1, 16);

	btn_hbox = gtk_hbox_new(TRUE, 4);
	gtk_box_pack_start(GTK_BOX(reg_hbox), btn_hbox, FALSE, FALSE, 0);

	reg_btn = gtk_button_new_from_stock(GTK_STOCK_ADD);
	gtk_box_pack_start(GTK_BOX(btn_hbox), reg_btn, FALSE, TRUE, 0);
	g_signal_connect(G_OBJECT(reg_btn), "clicked",
			 G_CALLBACK(prefs_filtering_action_register_cb), NULL);

	subst_btn = gtkut_get_replace_btn(_("_Replace"));
	gtk_box_pack_start(GTK_BOX(btn_hbox), subst_btn, FALSE, TRUE, 0);
	g_signal_connect(G_OBJECT(subst_btn), "clicked",
			 G_CALLBACK(prefs_filtering_action_substitute_cb),
			 NULL);

	del_btn = gtk_button_new_with_mnemonic (_("Re_move"));
	gtk_button_set_image(GTK_BUTTON(del_btn),
			gtk_image_new_from_stock(GTK_STOCK_REMOVE,GTK_ICON_SIZE_BUTTON));
	gtk_box_pack_start(GTK_BOX(btn_hbox), del_btn, FALSE, TRUE, 0);
	g_signal_connect(G_OBJECT(del_btn), "clicked",
			 G_CALLBACK(prefs_filtering_action_delete_cb), NULL);

	action_hbox = gtk_hbox_new(FALSE, 8);
	gtk_box_pack_start(GTK_BOX(vbox1), action_hbox, TRUE, TRUE, 0);

	action_scrolledwin = gtk_scrolled_window_new(NULL, NULL);
	gtk_widget_set_size_request(action_scrolledwin, -1, 150);
	gtk_box_pack_start(GTK_BOX(action_hbox), action_scrolledwin,
			   TRUE, TRUE, 0);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(action_scrolledwin),
					    GTK_SHADOW_ETCHED_IN);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(action_scrolledwin),
				       GTK_POLICY_AUTOMATIC,
				       GTK_POLICY_AUTOMATIC);

	action_list_view = prefs_filtering_action_list_view_create();
	gtk_container_add(GTK_CONTAINER(action_scrolledwin), action_list_view);

	btn_vbox = gtk_vbox_new(FALSE, 8);
	gtk_box_pack_start(GTK_BOX(action_hbox), btn_vbox, FALSE, FALSE, 0);

	up_btn = gtk_button_new_from_stock(GTK_STOCK_GO_UP);
	gtk_box_pack_start(GTK_BOX(btn_vbox), up_btn, FALSE, FALSE, 0);
	g_signal_connect(G_OBJECT(up_btn), "clicked",
			 G_CALLBACK(prefs_filtering_action_up), NULL);

	down_btn = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN);
	gtk_box_pack_start(GTK_BOX(btn_vbox), down_btn, FALSE, FALSE, 0);
	g_signal_connect(G_OBJECT(down_btn), "clicked",
			 G_CALLBACK(prefs_filtering_action_down), NULL);

	if (!geometry.min_height) {
		geometry.min_width = 490;
		geometry.min_height = 348;
	}

	gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
				      GDK_HINT_MIN_SIZE);
	gtk_widget_set_size_request(window, prefs_common.filteringactionwin_width,
				    prefs_common.filteringactionwin_height);

	gtk_widget_show_all(window);

	filtering_action.window    = window;
	filtering_action.label1 = label1;
	filtering_action.label2 = label2;
	filtering_action.label3 = label3;
	filtering_action.action_combo = action_combo;
	filtering_action.account_combo = account_combo;
	filtering_action.tags_combo = tags_combo;
	filtering_action.dest_entry = dest_entry;
	filtering_action.dest_btn = dest_btn;
	filtering_action.exec_btn = exec_btn;
#if !GTK_CHECK_VERSION(3, 0, 0)
	filtering_action.color_optmenu = color_optmenu;
#endif
	filtering_action.score_entry = score_entry;
	filtering_action.header_combo = header_combo;
	filtering_action.header_entry = header_entry;
#ifndef USE_ALT_ADDRBOOK
	filtering_action.addressbook_btn = addressbook_btn;
#endif
	filtering_action.ok_btn = ok_btn;
	filtering_action.action_list_view = action_list_view;
	
	prefs_filtering_action_type_selection_changed(NULL, NULL);
}
static void
power_manager_plugin_configure (XfcePanelPlugin      *plugin,
                                PowerManagerPlugin   *power_manager_plugin)
{
  GtkWidget *dialog;
  GtkWidget *grid, *combo, *label;
  gint show_panel_label;
  XfconfChannel   *channel;
  GtkListStore *list_store;
  GtkTreeIter iter, active_iter;
  GtkCellRenderer *cell;
  gint i;
  gchar *options[] = { _("None"), _("Percentage"), _("Remaining time"), _("Percentage and remaining time") };

  channel = xfconf_channel_get (XFPM_CHANNEL);

  /* block the plugin menu */
  xfce_panel_plugin_block_menu (plugin);

  /* create the dialog */
  dialog = xfce_titled_dialog_new_with_buttons (_("Power Manager Plugin Settings"),
                                                GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
                                                GTK_DIALOG_DESTROY_WITH_PARENT,
                                                "gtk-help", GTK_RESPONSE_HELP,
                                                "gtk-close", GTK_RESPONSE_OK,
                                                NULL);
  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
  gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-power-manager-settings");
  gtk_widget_show (dialog);

  /* Set up the main grid for all settings */
  grid = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
  gtk_widget_set_margin_start (grid, 12);
  gtk_widget_set_margin_end (grid, 12);
  gtk_widget_set_margin_top (grid, 12);
  gtk_widget_set_margin_bottom (grid, 12);
  gtk_container_add_with_properties (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
						                         grid, "expand", TRUE, "fill", TRUE, NULL);

  /* show-panel-label setting */
  label = gtk_label_new (_("Show label:"));
  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
  gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (label), 0, 0, 1, 1);
  show_panel_label = xfconf_channel_get_int (channel, XFPM_PROPERTIES_PREFIX SHOW_PANEL_LABEL, -1);

  list_store = gtk_list_store_new (N_COLUMNS,
                                   G_TYPE_INT,
                                   G_TYPE_STRING);

  for (i = 0; i < 4; i++) {
    gtk_list_store_append (list_store, &iter);
    gtk_list_store_set (list_store, &iter,
                        COLUMN_INT, i,
                        COLUMN_STRING, options[i],
                        -1);
    if (i == show_panel_label)
      active_iter = iter;
  }
  combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store));
  cell = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE );
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell, "text", COLUMN_STRING, NULL);
  gtk_combo_box_set_id_column (GTK_COMBO_BOX (combo), COLUMN_STRING);
  gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &active_iter);
  gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (combo), 1, 0, 1, 1);
  g_signal_connect (G_OBJECT (combo), "changed",
                    G_CALLBACK (power_manager_plugin_combo_changed),
                    channel);
  g_signal_connect (G_OBJECT (channel), "property-changed::" XFPM_PROPERTIES_PREFIX SHOW_PANEL_LABEL,
                    G_CALLBACK (power_manager_plugin_panel_label_changed),
                    combo);

  /* link the dialog to the plugin, so we can destroy it when the plugin
   * is closed, but the dialog is still open */
  g_object_set_data (G_OBJECT (plugin), "dialog", dialog);

  g_signal_connect (G_OBJECT (dialog), "response",
                    G_CALLBACK(power_manager_plugin_configure_response), power_manager_plugin);
  gtk_widget_show_all (grid);
}
Esempio n. 22
0
/**
 * fm_app_chooser_combo_box_setup
 * @combo: a #GtkComboBox
 * @mime_type: (allow-none): a #FmMimeType to select application
 * @apps: (allow-none) (element-type GAppInfo): custom list of applications
 * @sel: (allow-none): a selected application in @apps
 *
 * Setups a combobox for selecting default application either for
 * specified mime-type or from a list of pre-defined applications.
 * If @mime_type is %NULL, and @sel is provided and found in the @apps,
 * then it will be selected. If @mime_type is not %NULL then default
 * application for the @mime_type will be selected.
 * When set up, the combobox will contain a list of available applications.
 *
 * Since: 0.1.5
 */
void fm_app_chooser_combo_box_setup(GtkComboBox* combo, FmMimeType* mime_type, GList* apps, GAppInfo* sel)
{
    FmAppChooserComboBoxData* data = g_slice_new0(FmAppChooserComboBoxData);
    GtkListStore* store = gtk_list_store_new(3, G_TYPE_ICON, G_TYPE_STRING, G_TYPE_APP_INFO);
    GtkTreeIter it;
    GList* l;
    GtkCellRenderer* render;

    gtk_cell_layout_clear(GTK_CELL_LAYOUT(combo));

    render = gtk_cell_renderer_pixbuf_new();
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), render, FALSE);
    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo), render, "gicon", 0);

    render = gtk_cell_renderer_text_new();
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), render, FALSE);
    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo), render, "text", 1);

    if(mime_type)
    {
        data->mime_type = fm_mime_type_ref(mime_type);
        apps = g_app_info_get_all_for_type(fm_mime_type_get_type(data->mime_type));
        sel =  g_app_info_get_default_for_type(fm_mime_type_get_type(data->mime_type), FALSE);
    }

    for(l = apps; l; l = l->next)
    {
        GAppInfo* app = G_APP_INFO(l->data);
        gtk_list_store_insert_with_values(store, &it, -1,
                           0, g_app_info_get_icon(app),
                           1, g_app_info_get_name(app),
                           2, app, -1);
        if(sel && g_app_info_equal(app, sel))
        {
            /* this is the initially selected app */
            data->initial_sel_iter = it;
            data->initial_sel_app = (GAppInfo*)g_object_ref(app);
        }
    }

    if(mime_type) /* if this list is retrived with g_app_info_get_all_for_type() */
    {
        if(apps)
        {
            g_list_foreach(apps, (GFunc)g_object_unref, NULL);
            g_list_free(apps);
        }
        if(sel)
            g_object_unref(sel);
    }

    gtk_list_store_append(store, &it); /* separator */
    data->separator_iter = it;

    /* other applications */
    gtk_list_store_insert_with_values(store, &it, -1,
                       0, NULL,
                       1, _("Customize"), // FIXME: should be "Customize..."
                       2, NULL, -1);
    data->other_apps_iter = it;
    gtk_combo_box_set_model(combo, GTK_TREE_MODEL(store));

    if(data->initial_sel_iter.user_data) /* intital selection is set */
    {
        data->prev_sel_iter = data->initial_sel_iter;
        gtk_combo_box_set_active_iter(combo, &data->initial_sel_iter);
    }
    gtk_combo_box_set_row_separator_func(combo, is_row_separator, data, NULL);
    g_object_unref(store);

    g_signal_connect(combo, "changed", G_CALLBACK(on_app_selected), data);
    g_object_set_qdata_full(G_OBJECT(combo), fm_qdata_id, data, free_data);
}
Esempio n. 23
0
static gboolean
remap_dialog (gint32  image_ID,
              guchar *map)
{
  GtkWidget       *dialog;
  GtkWidget       *vbox;
  GtkWidget       *box;
  GtkWidget       *iconview;
  GtkListStore    *store;
  GtkCellRenderer *renderer;
  GtkTreeIter      iter;
  guchar          *cmap;
  gint             ncols, i;
  gboolean         valid;

  gimp_ui_init (PLUG_IN_BINARY, FALSE);

  dialog = gimp_dialog_new (_("Rearrange Colormap"), PLUG_IN_ROLE,
                            NULL, 0,
                            gimp_standard_help_func, PLUG_IN_PROC_REMAP,

                            GIMP_STOCK_RESET, RESPONSE_RESET,
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,

                            NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                           RESPONSE_RESET,
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  gimp_window_set_transient (GTK_WINDOW (dialog));

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                      vbox, TRUE, TRUE, 0);

  cmap = gimp_image_get_colormap (image_ID, &ncols);

  g_return_val_if_fail ((ncols > 0) && (ncols <= 256), FALSE);

  store = gtk_list_store_new (NUM_COLS,
                              G_TYPE_INT, G_TYPE_STRING, GIMP_TYPE_RGB,
                              G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_DOUBLE);

  for (i = 0; i < ncols; i++)
    {
      GimpRGB  rgb;
      GimpHSV  hsv;
      gint     index = map[i];
      gchar   *text  = g_strdup_printf ("%d", index);

      gimp_rgb_set_uchar (&rgb,
                          cmap[index * 3],
                          cmap[index * 3 + 1],
                          cmap[index * 3 + 2]);
      gimp_rgb_to_hsv (&rgb, &hsv);

      reverse_order[i] = ncols - i - 1;

      gtk_list_store_append (store, &iter);
      gtk_list_store_set (store, &iter,
                          COLOR_INDEX,      index,
                          COLOR_INDEX_TEXT, text,
                          COLOR_RGB,        &rgb,
                          COLOR_H,          hsv.h,
                          COLOR_S,          hsv.s,
                          COLOR_V,          hsv.v,
                          -1);
      g_free (text);
    }

  g_free (cmap);

  remap_ui = remap_ui_manager_new (dialog, store);

  iconview = gtk_icon_view_new_with_model (GTK_TREE_MODEL (store));
  g_object_unref (store);

  gtk_box_pack_start (GTK_BOX (vbox), iconview, TRUE, TRUE, 0);

  gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (iconview),
                                    GTK_SELECTION_SINGLE);
  gtk_icon_view_set_orientation (GTK_ICON_VIEW (iconview),
                                 GTK_ORIENTATION_VERTICAL);
  gtk_icon_view_set_columns (GTK_ICON_VIEW (iconview), 16);
  gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (iconview), 0);
  gtk_icon_view_set_column_spacing (GTK_ICON_VIEW (iconview), 0);
  gtk_icon_view_set_reorderable (GTK_ICON_VIEW (iconview), TRUE);

  renderer = gimp_cell_renderer_color_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (iconview), renderer, TRUE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (iconview), renderer,
                                  "color", COLOR_RGB,
                                  NULL);
  g_object_set (renderer,
                "width", 24,
                NULL);

  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (iconview), renderer, TRUE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (iconview), renderer,
                                  "text", COLOR_INDEX_TEXT,
                                  NULL);
  g_object_set (renderer,
                "size-points", 6.0,
                "xalign",      0.5,
                "ypad",        0,
                NULL);

  g_signal_connect (iconview, "popup-menu",
                    G_CALLBACK (remap_popup_menu),
                    NULL);

  g_signal_connect (iconview, "button-press-event",
                    G_CALLBACK (remap_button_press),
                    NULL);

  box = gimp_hint_box_new (_("Drag and drop colors to rearrange the colormap.  "
                             "The numbers shown are the original indices.  "
                             "Right-click for a menu with sort options."));

  gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, FALSE, 0);
  gtk_widget_show (box);

  g_signal_connect (dialog, "response",
                    G_CALLBACK (remap_response),
                    store);

  gtk_widget_show_all (dialog);

  gtk_main ();

  i = 0;

  for (valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
       valid;
       valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter))
    {
      gint index;

      gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
                          COLOR_INDEX, &index,
                          -1);
      map[i++] = index;
    }

  gtk_widget_destroy (dialog);

  return remap_run;
}
Esempio n. 24
0
static GtkWidget *create_window(GtkWidget *tree_view, gint window_id)
{
	GtkWidget *window;
	gchar *title;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *button;
	GtkWidget *label;
	GtkWidget *scrolled_window;
	GtkWidget *combobox_field;
	GtkWidget *combobox_comp;
	
	GtkWidget *expander;
	GtkWidget *hbox_1, *vbox_1, *Frame_1;
	GtkWidget *scrolled_window_1;
	GtkWidget *hbox_11;
	
	GtkTreeSelection *selection;
	GtkTreeModel *model;
	GtkTreeModel *child_model;
	gulong changed_handler_id;
	GList *list;
	
    GtkCellRenderer *column;
	
	char *c_label;
	
	c_label = (char *)calloc(KCHARA_C, sizeof(char));
	
	
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	title = g_strdup_printf("GtkTreeModelSort #%d", window_id);
	gtk_window_set_title(GTK_WINDOW(window), title);
	g_free(title);

	vbox = gtk_vbox_new(FALSE, 0);

	hbox = gtk_hbox_new(FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

	/* Delete data bottun */
	button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
	g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(remove_model_data), tree_view);

	/* Close window bottun */
	button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
	g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(cb_close_window), window);

	/* ラベル */
	label = gtk_label_new("");
	gtk_box_pack_end(GTK_BOX(hbox), label, TRUE, TRUE, 0);

	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_widget_set_size_request(scrolled_window, 400, 300);
	gtk_container_add(GTK_CONTAINER(scrolled_window), tree_view);
	gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);

	/*
	 * selectionにchangedシグナルハンドラを登録する。
	 * 後で同じchild_modelを使用しているselectionのchangedシグナルをブロック出来るように
	 * child_modelにselectionのリストを、selectionにシグナルハンドラIDを登録する。
	 * changedハンドラ内で使用するlabelも同様に登録しておく。
	 */
	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
	changed_handler_id = g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(sum_selected_rows), NULL);
	g_object_set_data(G_OBJECT(selection), "changed_handler_id", GUINT_TO_POINTER(changed_handler_id));
	g_object_set_data(G_OBJECT(selection), "label", label);

	model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
	child_model = gtk_tree_model_sort_get_model(GTK_TREE_MODEL_SORT(model));
	list = g_object_get_data(G_OBJECT(child_model), "selection_list");
	list = g_list_append(list, selection);
	g_object_set_data(G_OBJECT(child_model), "selection_list", list);
	
	
	
	get_label_MHD_control_head(c_label);
	expander = gtk_expander_new_with_mnemonic("Field to add");
	
	vbox_1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
	Frame_1 = gtk_frame_new("");
	gtk_frame_set_shadow_type(GTK_FRAME(Frame_1), GTK_SHADOW_IN);
	gtk_container_add(GTK_CONTAINER(Frame_1), vbox_1);
	
	/* Add data bottun */
	hbox_1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
	button = gtk_button_new_from_stock(GTK_STOCK_ADD);
	gtk_box_pack_start(GTK_BOX(hbox_1), button, FALSE, FALSE, 0);
	g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(append_model_data), tree_view);

	gtk_box_pack_start(GTK_BOX(hbox_1), gtk_label_new("  "), FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox_1), Frame_1, TRUE, TRUE, 0);
	gtk_container_add(GTK_CONTAINER(expander), hbox_1);
	gtk_box_pack_start(GTK_BOX(vbox), expander, TRUE, TRUE, 0);
	
	
	hbox_11 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
	combobox_field = gtk_combo_box_new_with_model(model);
	g_signal_connect(G_OBJECT(combobox_field), "changed", 
				G_CALLBACK(format_entry_text_callback), tree_view);
	column = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox_field), column, TRUE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox_field), column,
				"text", COLUMN_FIELD_NAME, NULL);
	gtk_box_pack_start(GTK_BOX(hbox_11), combobox_field, FALSE, FALSE, 0);
	
	combobox_comp = gtk_combo_box_new();
	g_signal_connect(G_OBJECT(combobox_comp), "changed", 
				G_CALLBACK(format_entry_text_callback), tree_view);
	column = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox_comp), column, TRUE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox_comp), column,
				"text", COLUMN_FIELD_NAME, NULL);
	gtk_box_pack_start(GTK_BOX(hbox_11), combobox_comp, FALSE, FALSE, 0);
	
	gtk_box_pack_start(GTK_BOX(vbox), hbox_11, FALSE, FALSE, 0);
	gtk_container_add(GTK_CONTAINER(window), vbox);

	gtk_widget_show_all(window);

	return window;
}
Esempio n. 25
0
/**
 * Initialize the buddy-add window.
 */
static void
hybrid_buddyadd_window_init(HybridBuddyAddWindow *window)
{
    GtkWidget       *vbox;
    GtkWidget       *action_area;
    GtkWidget       *label;
    GtkTreeModel    *model;
    GtkCellRenderer *renderer;
    GtkWidget       *button;
    GtkWidget       *table;
    GtkWidget       *scroll;

    HybridAccount *account = NULL;
    GtkTreeIter    iter;

    vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(window->window), vbox);

    table = gtk_table_new(5, 2, FALSE);
    gtk_table_set_row_spacings(GTK_TABLE(table), 5);
    gtk_table_set_col_spacings(GTK_TABLE(table), 5);
    gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);

    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), _("<b>Account:</b>"));
    gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);

    model = create_account_model();
    window->account_combo = gtk_combo_box_new_with_model(model);
    g_signal_connect(window->account_combo, "changed",
                    G_CALLBACK(account_changed_cb), window);
    renderer = gtk_cell_renderer_pixbuf_new ();
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(window->account_combo),
                                renderer, FALSE);
    gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(window->account_combo),
                                renderer, "pixbuf", 0, NULL);
    renderer = gtk_cell_renderer_text_new();
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(window->account_combo),
                                renderer, FALSE);
    gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(window->account_combo),
                                renderer, "text", 1, NULL);
    gtk_combo_box_set_active(GTK_COMBO_BOX(window->account_combo), 0);

    gtk_widget_set_size_request(window->account_combo, 270, 30);
    gtk_table_attach_defaults(GTK_TABLE(table), window->account_combo, 1, 2, 0, 1);

    /* username */
    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), _("<b>Username:</b>"));
    gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);

    window->username_entry = gtk_entry_new();
    gtk_widget_set_size_request(window->username_entry, 270, 30);
    gtk_table_attach_defaults(GTK_TABLE(table), window->username_entry, 1, 2, 1, 2);

    /* alias name */
    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), _("<b>Alias(Optional):</b>"));
    gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3);

    window->localname_entry = gtk_entry_new();
    gtk_widget_set_size_request(window->localname_entry, 270, 30);
    gtk_table_attach_defaults(GTK_TABLE(table), window->localname_entry, 1, 2, 2, 3);

    /* add-to-group combo box. */
    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), _("<b>Add To Group:</b>"));
    gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4);

    /* get the active account. */
    if (gtk_combo_box_get_active_iter(
                GTK_COMBO_BOX(window->account_combo), &iter)) {
        gtk_tree_model_get(model, &iter,
                BUDDYADD_ACCOUNT_COLUMN, &account,
                -1);
    }

    /* unref the account model. */
    g_object_unref(model);

    model = create_group_model(account);
    window->group_combo = gtk_combo_box_new_with_model(model);
    g_object_unref(model);

    renderer = gtk_cell_renderer_text_new();
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(window->group_combo),
                                renderer, FALSE);
    gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(window->group_combo),
                                renderer, "text",
                                BUDDYADD_GROUP_NAME_COLUMN, NULL);

    gtk_combo_box_set_active(GTK_COMBO_BOX(window->group_combo), 0);
    gtk_table_attach_defaults(GTK_TABLE(table), window->group_combo, 1, 2, 3, 4);

    /* add-buddy request tips. */
    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), _("<b>Tips(Optional):</b>"));
    gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 4, 5);

    scroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
            GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll),
            GTK_SHADOW_ETCHED_IN);
    window->tips_textview = gtk_text_view_new();
    gtk_widget_set_size_request(window->tips_textview, 270, 0);
    gtk_container_add(GTK_CONTAINER(scroll), window->tips_textview);
    gtk_table_attach_defaults(GTK_TABLE(table), scroll, 1, 2, 4, 5);

    /* buttons */
    action_area = gtk_hbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), action_area, FALSE, FALSE, 5);

    button = gtk_button_new_with_label(_("Add"));
    gtk_widget_set_size_request(button, 100, 30);
    gtk_box_pack_end(GTK_BOX(action_area), button, FALSE, FALSE, 5);
    g_signal_connect(button, "clicked", G_CALLBACK(add_cb), window);

    button = gtk_button_new_with_label(_("Cancel"));
    gtk_widget_set_size_request(button, 100, 30);
    gtk_box_pack_end(GTK_BOX(action_area), button, FALSE, FALSE, 5);
    g_signal_connect(button, "clicked", G_CALLBACK(cancel_cb), window);
}
Esempio n. 26
0
int
main (int argc, char **argv)
{
        GtkWidget *window, *cellview, *mainbox;
        GtkWidget *combobox, *comboboxtext, *comboboxgrid;
        GtkWidget *tmp, *boom;
        GtkCellRenderer *renderer;
        GtkTreeModel *model;
	GtkTreePath *path;
	GtkTreeIter iter;
	GdkRGBA color;
	GtkCellArea *area;
        gchar *text;
        gint i;

        gtk_init (&argc, &argv);

	if (g_getenv ("RTL"))
	  gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);

	if (g_getenv ("LISTMODE"))
	  {
	    GtkCssProvider *provider = gtk_css_provider_new ();

	    gtk_css_provider_load_from_data (provider,
					     "* { -GtkComboBox-appears-as-list: true; }", 
					     -1, NULL);

	    gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
						       GTK_STYLE_PROVIDER (provider),
						       GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);

	  }

        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_container_set_border_width (GTK_CONTAINER (window), 5);
        g_signal_connect (window, "destroy", gtk_main_quit, NULL);

        mainbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
        gtk_container_add (GTK_CONTAINER (window), mainbox);

        /* GtkCellView */
        tmp = gtk_frame_new ("GtkCellView");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        cellview = gtk_cell_view_new ();
        renderer = gtk_cell_renderer_pixbuf_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cellview),
                                    renderer,
                                    FALSE);
        g_object_set (renderer, "icon-name", "dialog-warning", NULL);

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cellview),
                                    renderer,
                                    TRUE);
        g_object_set (renderer, "text", "la la la", NULL);
        gtk_container_add (GTK_CONTAINER (boom), cellview);

        /* GtkComboBox list */
        tmp = gtk_frame_new ("GtkComboBox (list)");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        model = create_list_blaat ();
        combobox = gtk_combo_box_new_with_model (model);
        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);

        renderer = gtk_cell_renderer_pixbuf_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    FALSE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "icon-name", 0,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 1,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);
	gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combobox), 
					      is_separator, NULL, NULL);
						
        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);

        /* GtkComboBox dynamic list */
        tmp = gtk_frame_new ("GtkComboBox (dynamic list)");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        model = create_empty_list_blaat ();
        combobox = gtk_combo_box_new_with_model (model);
	g_signal_connect (combobox, "notify::popup-shown", 
			  G_CALLBACK (populate_list_blaat), combobox);

        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);

        renderer = gtk_cell_renderer_pixbuf_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    FALSE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "icon-name", 0,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 1,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);
	gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combobox), 
					      is_separator, NULL, NULL);
						
        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);

        /* GtkComboBox custom entry */
        tmp = gtk_frame_new ("GtkComboBox (custom)");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        model = create_list_blaat ();
        combobox = gtk_combo_box_new_with_model (model);
        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);

        renderer = gtk_cell_renderer_pixbuf_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    FALSE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "icon-name", 0,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 1,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);
	gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combobox), 
					      is_separator, NULL, NULL);
						
        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);

        tmp = gtk_cell_view_new ();
        gtk_widget_show (tmp);
        gtk_cell_view_set_model (GTK_CELL_VIEW (tmp), model);

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (tmp), renderer, TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (tmp), renderer,
                                        "text", 1,
                                        NULL);
        color.red = 1.0;
        color.blue = 1.0;
        color.green = 0;
        color.alpha = 1.0;
        gtk_cell_view_set_background_rgba (GTK_CELL_VIEW (tmp), &color);
        displayed_row_changed (GTK_COMBO_BOX (combobox), GTK_CELL_VIEW (tmp));
        g_signal_connect (combobox, "changed", G_CALLBACK (displayed_row_changed), tmp); 
           
        gtk_container_add (GTK_CONTAINER (combobox), tmp);

        /* GtkComboBox tree */
        tmp = gtk_frame_new ("GtkComboBox (tree)");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        model = create_tree_blaat ();
        combobox = gtk_combo_box_new_with_model (model);
        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);

        renderer = gtk_cell_renderer_pixbuf_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    FALSE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "icon-name", 0,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 1,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    set_sensitive,
					    NULL, NULL);
	gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combobox), 
					      is_separator, NULL, NULL);
						
        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
#if 0
	g_timeout_add (1000, (GSourceFunc) animation_timer, model);
#endif

        /* GtkComboBox (grid mode) */
        tmp = gtk_frame_new ("GtkComboBox (grid mode)");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        comboboxgrid = create_combo_box_grid_demo ();
        gtk_box_pack_start (GTK_BOX (boom), comboboxgrid, FALSE, FALSE, 0);


        /* GtkComboBoxEntry */
        tmp = gtk_frame_new ("GtkComboBox with entry");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        comboboxtext = gtk_combo_box_text_new_with_entry ();
        setup_combo_entry (GTK_COMBO_BOX_TEXT (comboboxtext));
        gtk_container_add (GTK_CONTAINER (boom), comboboxtext);


        /* Phylogenetic tree */
        tmp = gtk_frame_new ("What are you ?");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        model = create_phylogenetic_tree ();
        combobox = gtk_combo_box_new_with_model (model);
        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);

        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 0,
                                        NULL);
	
        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);

        /* Capitals */
        tmp = gtk_frame_new ("Where are you ?");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        model = create_capital_tree ();
	combobox = gtk_combo_box_new_with_model (model);
        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);
        renderer = gtk_cell_renderer_text_new ();
        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox),
                                    renderer,
                                    TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 0,
                                        NULL);
	gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combobox),
					    renderer,
					    capital_sensitive,
					    NULL, NULL);
	path = gtk_tree_path_new_from_indices (0, 8, -1);
	gtk_tree_model_get_iter (model, &iter, path);
	gtk_tree_path_free (path);
        gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);

#if 1
	gdk_threads_add_timeout (1000, (GSourceFunc) capital_animation, model);
#endif

        /* Aligned Food */
        tmp = gtk_frame_new ("Hungry ?");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

        model = create_food_list ();
	combobox = gtk_combo_box_new_with_model (model);
        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);

	area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (combobox));

        renderer = gtk_cell_renderer_text_new ();
	gtk_cell_area_add_with_properties (area, renderer, 
					   "align", TRUE, 
					   "expand", TRUE, 
					   NULL);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 0,
                                        NULL);

        renderer = gtk_cell_renderer_text_new ();
	gtk_cell_area_add_with_properties (area, renderer, 
					   "align", TRUE, 
					   "expand", TRUE, 
					   NULL);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 1,
                                        NULL);

        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);

	/* Ellipsizing growing combos */
        tmp = gtk_frame_new ("Unconstrained Menu");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);

        boom = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_set_border_width (GTK_CONTAINER (boom), 5);
        gtk_container_add (GTK_CONTAINER (tmp), boom);

	model = create_list_long ();
	combobox = gtk_combo_box_new_with_model (model);
        g_object_unref (model);
        gtk_container_add (GTK_CONTAINER (boom), combobox);
        renderer = gtk_cell_renderer_text_new ();
	g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);

        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
                                        "text", 0, NULL);
        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
	gtk_combo_box_set_popup_fixed_width (GTK_COMBO_BOX (combobox), FALSE);

        tmp = gtk_frame_new ("Looong");
        gtk_box_pack_start (GTK_BOX (mainbox), tmp, FALSE, FALSE, 0);
        combobox = gtk_combo_box_text_new ();
        for (i = 0; i < 200; i++)
          {
            text = g_strdup_printf ("Item %d", i);
            gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combobox), text);
            g_free (text);
          }
        gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 53);
        gtk_container_add (GTK_CONTAINER (tmp), combobox);

        gtk_widget_show_all (window);

        gtk_main ();

        return 0;
}
Esempio n. 27
0
void
ags_oscillator_init(AgsOscillator *oscillator)
{
  GtkTable *table;
  GtkCellRenderer *cell_renderer;
  GtkListStore *model;
  GtkTreeIter iter;

  table = (GtkTable *) gtk_table_new(8, 2, FALSE);
  gtk_container_add((GtkContainer *) oscillator, (GtkWidget *) table);

  gtk_table_attach_defaults(table,
			    (GtkWidget *) gtk_label_new("wave\0"),
			    0, 1, 0, 1);

  /* wave */
  oscillator->wave = (GtkComboBox *) gtk_combo_box_text_new();
  gtk_table_attach_defaults(table,
			    (GtkWidget *) oscillator->wave,
			    1, 2, 0, 1);

  cell_renderer = gtk_cell_renderer_text_new();
  gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(oscillator->wave),
			     cell_renderer,
			     FALSE); 
  gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(oscillator->wave),
				 cell_renderer,
				 "text\0", 0,
				 NULL);

  model = gtk_list_store_new(1, G_TYPE_STRING);

  gtk_list_store_append(model, &iter);
  gtk_list_store_set(model, &iter,
		     0, "sin\0",
		     -1);

  /*  gtk_list_store_append(model, &iter);
  gtk_list_store_set(model, &iter,
		     0, "cos\0",
		     -1);  */

  gtk_list_store_append(model, &iter);
  gtk_list_store_set(model, &iter,
		     0, "sawtooth\0",
		     -1);

  gtk_list_store_append(model, &iter);
  gtk_list_store_set(model, &iter,
		     0, "square\0",
		     -1);

  gtk_list_store_append(model, &iter);
  gtk_list_store_set(model, &iter,
		     0, "triangle\0",
		     -1);

  gtk_combo_box_set_model(oscillator->wave, GTK_TREE_MODEL(model));
  gtk_combo_box_set_active(oscillator->wave, 0);

  /* other controls */
  gtk_table_attach_defaults(table,
			    (GtkWidget *) gtk_label_new("attack\0"),
			    2, 3, 0, 1);
  oscillator->attack = (GtkSpinButton *) gtk_spin_button_new_with_range(0.0, 100000.0, 1.0);
  oscillator->attack->adjustment->value = 0.0;
  gtk_table_attach_defaults(table, (GtkWidget *) oscillator->attack, 3, 4, 0, 1);

  gtk_table_attach_defaults(table,
			    (GtkWidget *) gtk_label_new("length\0"),
			    4, 5, 0, 1);
  oscillator->frame_count = (GtkSpinButton *) gtk_spin_button_new_with_range(44100.0 / 27.5, 100000.0, 1.0);
  oscillator->frame_count->adjustment->value = 3200;
  gtk_table_attach_defaults(table, (GtkWidget *) oscillator->frame_count, 5, 6, 0, 1);

  gtk_table_attach_defaults(table,
			    (GtkWidget *) gtk_label_new("phase\0"),
			    0, 1, 1, 2);
  oscillator->phase = (GtkSpinButton *) gtk_spin_button_new_with_range(0.0, 100000.0, 1.0);
  oscillator->phase->adjustment->value = 0.0;
  gtk_table_attach_defaults(table, (GtkWidget *) oscillator->phase, 1, 2, 1, 2);

  gtk_table_attach_defaults(table,
			    (GtkWidget *) gtk_label_new("frequency\0"),
			    2, 3, 1, 2);
  oscillator->frequency = (GtkSpinButton *) gtk_spin_button_new_with_range(0.0, 100000.0, 1.0);
  oscillator->frequency->adjustment->value = 27.5;
  gtk_table_attach_defaults(table, (GtkWidget *) oscillator->frequency, 3, 4, 1, 2);

  gtk_table_attach_defaults(table,
			    (GtkWidget *) gtk_label_new("volume\0"),
			    4, 5, 1, 2);
  oscillator->volume = (GtkSpinButton *) gtk_spin_button_new_with_range(0.0, 1.0, 0.1);
  oscillator->volume->adjustment->value = 0.2;
  gtk_table_attach_defaults(table, (GtkWidget *) oscillator->volume, 5, 6, 1, 2);
}
Esempio n. 28
0
static GtkWidget *
create_combo_box_grid_demo (void)
{
        GtkWidget *combo;
        GtkTreeIter iter;
        GdkPixbuf *pixbuf;
        GtkCellRenderer *cell = gtk_cell_renderer_pixbuf_new ();
        GtkListStore *store;

        store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_INT);

        /* first row */
        pixbuf = create_color_pixbuf ("red");
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, pixbuf,
                            1, 1, /* row span */
                            2, 1, /* column span */
                            -1);
        g_object_unref (pixbuf);

        pixbuf = create_color_pixbuf ("green");
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, pixbuf,
                            1, 1,
                            2, 1,
                            -1);
        g_object_unref (pixbuf);

        pixbuf = create_color_pixbuf ("blue");
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, pixbuf,
                            1, 1,
                            2, 1,
                            -1);
        g_object_unref (pixbuf);

        /* second row */
        pixbuf = create_color_pixbuf ("yellow");
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, pixbuf,
                            1, 1,
                            2, 2, /* Span 2 columns */
                            -1);
        g_object_unref (pixbuf);

        pixbuf = create_color_pixbuf ("black");
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, pixbuf,
                            1, 2, /* Span 2 rows */
                            2, 1,
                            -1);
        g_object_unref (pixbuf);

        /* third row */
        pixbuf = create_color_pixbuf ("gray");
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, pixbuf,
                            1, 1,
                            2, 1,
                            -1);
        g_object_unref (pixbuf);

        pixbuf = create_color_pixbuf ("magenta");
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter,
                            0, pixbuf,
                            1, 1,
                            2, 1,
                            -1);
        g_object_unref (pixbuf);

        /* Create ComboBox after model to avoid gtk_menu_attach() warnings(?) */
        combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
        g_object_unref (store);

        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo),
                                    cell, TRUE);
        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
                                        cell, "pixbuf", 0, NULL);

        /* Set wrap-width != 0 to enforce grid mode */
        gtk_combo_box_set_wrap_width (GTK_COMBO_BOX (combo), 3);
        gtk_combo_box_set_row_span_column (GTK_COMBO_BOX (combo), 1);
        gtk_combo_box_set_column_span_column (GTK_COMBO_BOX (combo), 2);

        gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);

        return combo;
}
Esempio n. 29
0
static void
eog_thumb_view_constructed (GObject *object)
{
	EogThumbView *thumbview;

	if (G_OBJECT_CLASS (eog_thumb_view_parent_class)->constructed)
		G_OBJECT_CLASS (eog_thumb_view_parent_class)->constructed (object);

	thumbview = EOG_THUMB_VIEW (object);

	thumbview->priv->pixbuf_cell = gtk_cell_renderer_pixbuf_new ();

	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (thumbview),
				    thumbview->priv->pixbuf_cell,
				    FALSE);

	g_object_set (thumbview->priv->pixbuf_cell,
	              "follow-state", FALSE,
	              "height", 100,
	              "width", 115,
	              "yalign", 0.5,
	              "xalign", 0.5,
	              NULL);

	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (thumbview),
					thumbview->priv->pixbuf_cell,
					"pixbuf", EOG_LIST_STORE_THUMBNAIL,
					NULL);

	gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (thumbview),
					  GTK_SELECTION_MULTIPLE);

	gtk_icon_view_set_column_spacing (GTK_ICON_VIEW (thumbview),
					  EOG_THUMB_VIEW_SPACING);

	gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (thumbview),
				       EOG_THUMB_VIEW_SPACING);

	g_object_set (thumbview, "has-tooltip", TRUE, NULL);

	g_signal_connect (thumbview,
			  "query-tooltip",
			  G_CALLBACK (thumbview_on_query_tooltip_cb),
			  NULL);

	thumbview->priv->start_thumb = 0;
	thumbview->priv->end_thumb = 0;
	thumbview->priv->menu = NULL;

	g_signal_connect (G_OBJECT (thumbview), "parent-set",
			  G_CALLBACK (thumbview_on_parent_set_cb), NULL);

	gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (thumbview), 0,
						NULL, 0,
						GDK_ACTION_COPY |
						GDK_ACTION_MOVE |
						GDK_ACTION_LINK |
						GDK_ACTION_ASK);
	gtk_drag_source_add_uri_targets (GTK_WIDGET (thumbview));

	g_signal_connect (G_OBJECT (thumbview), "drag-data-get",
			  G_CALLBACK (thumbview_on_drag_data_get_cb), NULL);
}
void
ags_audio_preferences_init(AgsAudioPreferences *audio_preferences)
{
  GtkTable *table;
  GtkLabel *label;
  GtkCellRenderer *cell_renderer;

  table = (GtkTable *) gtk_table_new(2, 4, FALSE);
  gtk_box_pack_start(GTK_BOX(audio_preferences),
		     GTK_WIDGET(table),
		     FALSE, FALSE,
		     2);

  /* sound card */
  label = (GtkLabel *) g_object_new(GTK_TYPE_LABEL,
				    "label\0", "sound card\0",
				    "xalign\0", 0.0,
				    NULL);
  gtk_table_attach(table,
		   GTK_WIDGET(label),
		   0, 1,
		   0, 1,
		   GTK_FILL, GTK_FILL,
		   0, 0);

  audio_preferences->card = (GtkComboBox *) gtk_combo_box_new();
  gtk_table_attach(table,
		   GTK_WIDGET(audio_preferences->card),
		   1, 2,
		   0, 1,
		   GTK_FILL, GTK_FILL,
		   0, 0);
  
  cell_renderer = gtk_cell_renderer_text_new();
  gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(audio_preferences->card),
			     cell_renderer,
			     FALSE); 
  gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(audio_preferences->card),
				 cell_renderer,
				 "text\0", 0,
				 "text\0", 1,
				 NULL);
  gtk_combo_box_set_active(audio_preferences->card, 0);
  
  /* audio channels */
  label = (GtkLabel *) g_object_new(GTK_TYPE_LABEL,
				    "label\0", "audio channels\0",
				    "xalign\0", 0.0,
				    NULL);
  gtk_table_attach(table,
		   GTK_WIDGET(label),
		   0, 1,
		   1, 2,
		   GTK_FILL, GTK_FILL,
		   0, 0);

  audio_preferences->audio_channels = (GtkSpinButton *) gtk_spin_button_new_with_range(1.0, 24.0, 1.0);
  gtk_spin_button_set_value(audio_preferences->audio_channels, 2);
  gtk_table_attach(table,
		   GTK_WIDGET(audio_preferences->audio_channels),
		   1, 2,
		   1, 2,
		   GTK_FILL, GTK_FILL,
		   0, 0);

  /* samplerate */
  label = (GtkLabel *) g_object_new(GTK_TYPE_LABEL,
				    "label\0", "samplerate\0",
				    "xalign\0", 0.0,
				    NULL);
  gtk_table_attach(table,
		   GTK_WIDGET(label),
		   0, 1,
		   2, 3,
		   GTK_FILL, GTK_FILL,
		   0, 0);

  audio_preferences->samplerate = (GtkSpinButton *) gtk_spin_button_new_with_range(1.0, 192000.0, 1.0);
  gtk_spin_button_set_value(audio_preferences->samplerate, 44100);
  gtk_table_attach(table,
		   GTK_WIDGET(audio_preferences->samplerate),
		   1, 2,
		   2, 3,
		   GTK_FILL, GTK_FILL,
		   0, 0);

  /* buffer size */
  label = (GtkLabel *) g_object_new(GTK_TYPE_LABEL,
				    "label\0", "buffer size\0",
				    "xalign\0", 0.0,
				    NULL);
  gtk_table_attach(table,
		   GTK_WIDGET(label),
		   0, 1,
		   3, 4,
		   GTK_FILL, GTK_FILL,
		   0, 0);

  audio_preferences->buffer_size = (GtkSpinButton *) gtk_spin_button_new_with_range(1.0, 65535.0, 1.0);
  gtk_spin_button_set_value(audio_preferences->buffer_size, 512);
  gtk_table_attach(table,
		   GTK_WIDGET(audio_preferences->buffer_size),
		   1, 2,
		   3, 4,
		   GTK_FILL, GTK_FILL,
		   0, 0);
}