コード例 #1
0
ファイル: plugin.c プロジェクト: VujinovM/anjuta
static void
add_recent_project_row (GtkListBox *recent_project_box, GtkRecentData *recent_project)
{
	GtkBuilder *builder;
	GFile *file;
	GtkWidget *recent_row;
	GtkLabel *project_label, *path_label;
	GError *error;

	error = NULL;
	builder = gtk_builder_new ();
	if (!gtk_builder_add_from_resource (builder, "/org/gnome/anjuta/ui/starter.ui", &error))
	{
		DEBUG_PRINT ("Could not load starter.ui! %s", error->message);
		g_error_free (error);
	}
	else
	{
		file = g_file_new_for_uri (gtk_recent_info_get_uri (recent_project));
		if (g_file_query_exists (file, NULL))
		{
			recent_row = GTK_WIDGET (gtk_builder_get_object (builder, RECENT_ROW));
			project_label = GTK_WIDGET (gtk_builder_get_object (builder, PROJECT_LABEL));
			path_label = GTK_WIDGET (gtk_builder_get_object (builder, PATH_LABEL));
			gtk_label_set_text (project_label, gtk_recent_info_get_display_name(recent_project));
			gtk_label_set_text (path_label, g_file_get_path(file));
			g_object_set_data_full (G_OBJECT (recent_row), URI_KEY, g_file_get_uri(file), g_free);
			gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (recent_row)), recent_row);
			gtk_list_box_insert (recent_project_box, recent_row, -1);
		}
		g_object_unref (file);

	}
	g_object_unref (builder);
}
コード例 #2
0
static void
gs_shell_category_create_filter_list (GsShellCategory *shell,
				      GsCategory *category,
				      GsCategory *subcategory)
{
	GsShellCategoryPrivate *priv = shell->priv;
	GtkWidget *row;
	GList *l;
	GsCategory *s;
	_cleanup_list_free_ GList *list = NULL;

	gs_container_remove_all (GTK_CONTAINER (priv->category_detail_grid));

	list = gs_category_get_subcategories (category);
	if (!list)
		return;

	gtk_grid_attach (GTK_GRID (priv->category_detail_grid), priv->col0_placeholder, 0, 0, 1, 1);
	gtk_grid_attach (GTK_GRID (priv->category_detail_grid), priv->col1_placeholder, 1, 0, 1, 1);

	gs_container_remove_all (GTK_CONTAINER (priv->listbox_filter));

	for  (l = list; l; l = l->next) {
		s = l->data;
		if (gs_category_get_size (s) < 1)
			continue;
		row = gtk_label_new (gs_category_get_name (s));
		g_object_set_data_full (G_OBJECT (row), "category", g_object_ref (s), g_object_unref);
		g_object_set (row, "xalign", 0.0, "margin", 10, NULL);
		gtk_widget_show (row);
		gtk_list_box_insert (GTK_LIST_BOX (priv->listbox_filter), row, -1);
		if (subcategory == s)
			gtk_list_box_select_row (GTK_LIST_BOX (priv->listbox_filter), GTK_LIST_BOX_ROW (gtk_widget_get_parent (row)));
	}
}
コード例 #3
0
static void
ide_editor_spell_widget__add_button_clicked_cb (IdeEditorSpellWidget *self,
                                                GtkButton            *button)
{
  const gchar *word;
  GtkWidget *item;
  GtkWidget *toplevel;
  GtkWidget *focused_widget;

  g_assert (IDE_IS_EDITOR_SPELL_WIDGET (self));
  g_assert (GTK_IS_BUTTON (button));

  word = gtk_entry_get_text (GTK_ENTRY (self->dict_word_entry));
  /* TODO: check if word already in dict */
  if (check_dict_available (self) && !ide_str_empty0 (word))
    {
      if (!ide_editor_spell_dict_add_word_to_personal (self->dict, word))
        return;

      item = dict_create_word_row (self, word);
      gtk_list_box_insert (GTK_LIST_BOX (self->dict_words_list), item, 0);

      toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
      if (GTK_IS_WINDOW (toplevel) &&
          NULL != (focused_widget = gtk_window_get_focus (GTK_WINDOW (toplevel))))
        {
          if (focused_widget != GTK_WIDGET (self->word_entry) &&
              focused_widget != self->dict_word_entry)
            gtk_widget_grab_focus (self->dict_word_entry);
        }

      gtk_entry_set_text (GTK_ENTRY (self->dict_word_entry), "");

    }
}
コード例 #4
0
ファイル: testlist3.c プロジェクト: Zekom/gtk
int
main (int argc, char *argv[])
{
    GtkWidget *window, *list, *sw, *row;
    GtkWidget *hbox, *vbox, *combo, *button;
    gint i;
    gchar *text;

    gtk_init (NULL, NULL);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size (GTK_WINDOW (window), -1, 300);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
    gtk_container_add (GTK_CONTAINER (window), hbox);
    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    g_object_set (vbox, "margin", 12, NULL);
    gtk_container_add (GTK_CONTAINER (hbox), vbox);

    list = gtk_list_box_new ();
    gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_NONE);

    g_signal_connect (list, "row-activated", G_CALLBACK (on_row_activated), NULL);
    g_signal_connect (list, "selected-rows-changed", G_CALLBACK (on_selected_children_changed), NULL);
    g_signal_connect (gtk_widget_get_accessible (list), "selection-changed", G_CALLBACK (a11y_selection_changed), NULL);

    sw = gtk_scrolled_window_new (NULL, NULL);
    gtk_widget_set_hexpand (sw, TRUE);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
    gtk_container_add (GTK_CONTAINER (hbox), sw);
    gtk_container_add (GTK_CONTAINER (sw), list);

    button = gtk_check_button_new_with_label ("Activate on single click");
    g_object_bind_property (list, "activate-on-single-click",
                            button, "active",
                            G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
    gtk_container_add (GTK_CONTAINER (vbox), button);

    combo = gtk_combo_box_text_new ();
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "None");
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "Single");
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "Browse");
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "Multiple");
    g_signal_connect (combo, "changed", G_CALLBACK (selection_mode_changed), list);
    gtk_container_add (GTK_CONTAINER (vbox), combo);
    gtk_combo_box_set_active (GTK_COMBO_BOX (combo), gtk_list_box_get_selection_mode (GTK_LIST_BOX (list)));

    for (i = 0; i < 20; i++)
    {
        text = g_strdup_printf ("Row %d", i);
        row = create_row (text);
        gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
    }

    gtk_widget_show_all (window);

    gtk_main ();

    return 0;
}
コード例 #5
0
ファイル: glade-gtk-list-box.c プロジェクト: kugel-/glade
static void
glade_gtk_listbox_insert (GtkListBox    *listbox,
                          GtkListBoxRow *row,
                          gint           position)
{
  gtk_list_box_insert (listbox, GTK_WIDGET (row), position);

  sync_row_positions (listbox);
}
コード例 #6
0
ファイル: subtitlehandler.c プロジェクト: Doluci/HandBrake
static void subtitle_def_lang_list_init(signal_user_data_t *ud)
{
    GValue *lang_list;

    // Clear selected languages.
    subtitle_def_selected_lang_list_clear(ud);

    lang_list = ghb_settings_get_value(ud->settings, "SubtitleLanguageList");
    if (lang_list == NULL)
    {
        lang_list = ghb_array_value_new(8);
        ghb_settings_set_value(ud->settings, "SubtitleLanguageList", lang_list);
    }

    int ii, count;
    count = ghb_array_len(lang_list);
    for (ii = 0; ii < count; )
    {
        GValue *lang_val = ghb_array_get_nth(lang_list, ii);
        int idx = ghb_lookup_audio_lang(lang_val);
        if (ii == 0)
        {
            const iso639_lang_t *lang;
            lang = ghb_iso639_lookup_by_int(idx);
            subtitle_update_pref_lang(ud, lang);
        }

        GtkListBox *avail, *selected;
        GtkListBoxRow *row;
        avail = GTK_LIST_BOX(GHB_WIDGET(ud->builder, "subtitle_avail_lang"));
        selected = GTK_LIST_BOX(GHB_WIDGET(ud->builder, "subtitle_selected_lang"));
        row = ghb_find_lang_row(avail, idx);
        if (row)
        {
            GtkWidget *label = gtk_bin_get_child(GTK_BIN(row));
            g_object_ref(G_OBJECT(label));
            gtk_widget_destroy(GTK_WIDGET(row));
            gtk_widget_show(label);
            gtk_list_box_insert(selected, label, -1);
            ii++;
        }
        else
        {
            // Error in list.  Probably duplicate languages.  Remove
            // this item from the list.
            GValue *glang = ghb_array_get_nth(lang_list, ii);
            ghb_array_remove(lang_list, ii);
            ghb_value_free(glang);
            count--;
        }
    }
    if (count == 0)
    {
        subtitle_update_pref_lang(ud, NULL);
    }
}
コード例 #7
0
ファイル: subtitlehandler.c プロジェクト: Doluci/HandBrake
static void subtitle_def_lang_list_clear_cb(GtkWidget *row, gpointer data)
{
    GtkListBox *avail = (GtkListBox*)data;
    GtkWidget *label = gtk_bin_get_child(GTK_BIN(row));
    g_object_ref(G_OBJECT(label));
    gtk_widget_destroy(GTK_WIDGET(row));
    gtk_widget_show(label);
    int idx = (intptr_t)g_object_get_data(G_OBJECT(label), "lang_idx");
    gtk_list_box_insert(avail, label, idx);
}
コード例 #8
0
ファイル: glade-gtk-list-box.c プロジェクト: kugel-/glade
static void
glade_gtk_listbox_reorder (GtkListBox    *listbox,
                           GtkListBoxRow *row,
                           gint           position)
{
  gtk_container_remove (GTK_CONTAINER (listbox), GTK_WIDGET (row));
  gtk_list_box_insert (listbox, GTK_WIDGET (row), position);

  sync_row_positions (listbox);
}
コード例 #9
0
static void
on_item_added (GcrCollection *collection, GObject *item, gpointer user_data)
{
    SeahorseKeyserverResults *self = SEAHORSE_KEYSERVER_RESULTS (user_data);
    g_autoptr(SeahorseKeyserverResultsRow) row = NULL;

    g_return_if_fail (G_IS_OBJECT (item));

    row = seahorse_keyserver_results_row_new (item);
    gtk_list_box_insert (self->key_list,
                         GTK_WIDGET (g_steal_pointer (&row)),
                         -1);
}
コード例 #10
0
static gboolean on_listbox_row_inserted(GtkTreeModel*       model,
                                        GtkTreePath*        path,
                                        GtkTreeIter*        iter,
                                        PrivateListBoxData* data)
{
    const gint* indices = gtk_tree_path_get_indices(path);
    GtkWidget* row = gtk_list_box_row_new();
    GtkWidget* content = data->new_widget();
    gtk_container_add(GTK_CONTAINER(row), content);
    g_object_set_data(G_OBJECT(row), LISTBOX_ITEM_PATH_PROP, gtk_tree_model_get_path(data->model, iter));
    gtk_list_box_insert(data->widget, row, indices[0]);
    gtk_widget_show_all(row);
    return FALSE;
}
コード例 #11
0
ファイル: subtitlehandler.c プロジェクト: Doluci/HandBrake
G_MODULE_EXPORT void
subtitle_remove_lang_clicked_cb(GtkWidget *widget, signal_user_data_t *ud)
{

    GtkListBox *avail, *selected;
    GtkListBoxRow *row;
    GtkWidget *label;

    avail = GTK_LIST_BOX(GHB_WIDGET(ud->builder, "subtitle_avail_lang"));
    selected = GTK_LIST_BOX(GHB_WIDGET(ud->builder, "subtitle_selected_lang"));
    row = gtk_list_box_get_selected_row(selected);
    if (row != NULL)
    {
        gint index;
        GValue *lang_list;

        index = gtk_list_box_row_get_index(row);

        // Remove from UI selected language list box
        label = gtk_bin_get_child(GTK_BIN(row));
        g_object_ref(G_OBJECT(label));
        int idx = (intptr_t)g_object_get_data(G_OBJECT(label), "lang_idx");
        gtk_widget_destroy(GTK_WIDGET(row));
        gtk_widget_show(label);
        // Add to UI available language list box
        gtk_list_box_insert(avail, label, idx);

        // Remove from preset language list
        lang_list = ghb_settings_get_value(ud->settings, "SubtitleLanguageList");
        GValue *glang = ghb_array_get_nth(lang_list, index);
        ghb_array_remove(lang_list, index);
        ghb_value_free(glang);

        ghb_clear_presets_selection(ud);

        if (ghb_array_len(lang_list) > 0)
        {
            const iso639_lang_t *lang;
            GValue *entry = ghb_array_get_nth(lang_list, 0);
            lang = ghb_iso639_lookup_by_int(ghb_lookup_audio_lang(entry));
            subtitle_update_pref_lang(ud, lang);
        }
        else
        {
            subtitle_update_pref_lang(ud, NULL);
        }
    }
}
コード例 #12
0
static void
dict_fill_listbox (IdeEditorSpellWidget *self,
                   GPtrArray            *words_array)
{
  gsize len;
  const gchar *word;
  GtkWidget *item;

  g_assert (IDE_IS_EDITOR_SPELL_WIDGET (self));
  g_assert (words_array != NULL);

  dict_clean_listbox (self);

  len = words_array->len;
  for (gint i = 0; i < len; ++i)
    {
      word = g_ptr_array_index (words_array, i);
      item = dict_create_word_row (self, word);
      gtk_list_box_insert (GTK_LIST_BOX (self->dict_words_list), item, -1);
    }
}
コード例 #13
0
static void
fill_suggestions_box (IdeEditorSpellWidget *self,
                      const gchar          *word,
                      gchar               **first_result)
{
  GSList *suggestions = NULL;
  GtkWidget *item;

  g_assert (IDE_IS_EDITOR_SPELL_WIDGET (self));
  g_assert (first_result != NULL);

  *first_result = NULL;

  clear_suggestions_box (self);
  if (ide_str_empty0 (word))
    {
      gtk_widget_set_sensitive (GTK_WIDGET (self->suggestions_box), FALSE);
      return;
    }

  if (NULL == (suggestions = gspell_checker_get_suggestions (self->checker, word, -1)))
    {
      gtk_label_set_text (GTK_LABEL (self->placeholder), _("No suggestions"));
      gtk_widget_set_sensitive (GTK_WIDGET (self->suggestions_box), FALSE);
    }
  else
    {
      *first_result = g_strdup (suggestions->data);
      gtk_widget_set_sensitive (GTK_WIDGET (self->suggestions_box), TRUE);
      for (GSList *l = (GSList *)suggestions; l != NULL; l = l->next)
        {
          item = create_suggestion_row (self, l->data);
          gtk_list_box_insert (self->suggestions_box, item, -1);
        }

      g_slist_free_full (suggestions, g_free);
    }
}
コード例 #14
0
ファイル: subtitlehandler.c プロジェクト: Doluci/HandBrake
G_MODULE_EXPORT void
subtitle_add_lang_clicked_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    GtkListBox *avail = GTK_LIST_BOX(GHB_WIDGET(ud->builder, "subtitle_avail_lang"));
    GtkListBox *selected = GTK_LIST_BOX(GHB_WIDGET(ud->builder, "subtitle_selected_lang"));
    GtkListBoxRow *row;
    GtkWidget *label;

    row = gtk_list_box_get_selected_row(avail);
    if (row != NULL)
    {
        int idx;
        const iso639_lang_t *lang;
        GValue *glang, *lang_list;

        // Remove from UI available language list box
        label = gtk_bin_get_child(GTK_BIN(row));
        g_object_ref(G_OBJECT(label));
        gtk_widget_destroy(GTK_WIDGET(row));
        gtk_widget_show(label);
        // Add to UI selected language list box
        gtk_list_box_insert(selected, label, -1);

        // Add to preset language list
        idx = (intptr_t)g_object_get_data(G_OBJECT(label), "lang_idx");
        lang = ghb_iso639_lookup_by_int(idx);
        glang = ghb_string_value_new(lang->iso639_2);
        lang_list = ghb_settings_get_value(ud->settings, "SubtitleLanguageList");
        if (ghb_array_len(lang_list) == 0)
        {
            subtitle_update_pref_lang(ud, lang);
        }
        ghb_array_append(lang_list, glang);
        ghb_clear_presets_selection(ud);
    }
}
コード例 #15
0
ファイル: widget-factory.c プロジェクト: Distrotech/gtk
static void
populate_colors (GtkWidget *widget)
{
  struct { const gchar *name; const gchar *color; const gchar *title; } colors[] = {
    { "2.5", "#C8828C", "Red" },
    { "5", "#C98286", NULL },
    { "7.5", "#C9827F", NULL },
    { "10", "#C98376", NULL },
    { "2.5", "#C8856D", "Red/Yellow" },
    { "5", "#C58764", NULL },
    { "7.5", "#C1895E", NULL },
    { "10", "#BB8C56", NULL },
    { "2.5", "#B58F4F", "Yellow" },
    { "5", "#AD924B", NULL },
    { "7.5", "#A79548", NULL },
    { "10", "#A09749", NULL },
    { "2.5", "#979A4E", "Yellow/Green" },
    { "5", "#8D9C55", NULL },
    { "7.5", "#7F9F62", NULL },
    { "10", "#73A06E", NULL },
    { "2.5", "#65A27C", "Green" },
    { "5", "#5CA386", NULL },
    { "7.5", "#57A38D", NULL },
    { "10", "#52A394", NULL },
    { "2.5", "#4EA39A", "Green/Blue" },
    { "5", "#49A3A2", NULL },
    { "7.5", "#46A2AA", NULL },
    { "10", "#46A1B1", NULL },
    { "2.5", "#49A0B8", "Blue" },
    { "5", "#529EBD", NULL },
    { "7.5", "#5D9CC1", NULL },
    { "10", "#689AC3", NULL },
    { "2.5", "#7597C5", "Blue/Purple" },
    { "5", "#8095C6", NULL },
    { "7.5", "#8D91C6", NULL },
    { "10", "#988EC4", NULL },
    { "2.5", "#A08CC1", "Purple" },
    { "5", "#A88ABD", NULL },
    { "7.5", "#B187B6", NULL },
    { "10", "#B786B0", NULL },
    { "2.5", "#BC84A9", "Purple/Red" },
    { "5", "#C183A0", NULL },
    { "7.5", "#C48299", NULL },
    { "10", "#C68292", NULL }
  };
  gint i;
  GtkWidget *row, *box, *label, *swatch;
  GtkWidget *sw;
  GdkRGBA rgba;

  gtk_list_box_set_header_func (GTK_LIST_BOX (widget), update_title_header, NULL, NULL);

  for (i = 0; i < G_N_ELEMENTS (colors); i++)
    {
      row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20);
      label = gtk_label_new (colors[i].name);
      g_object_set (label,
                    "halign", GTK_ALIGN_START,
                    "valign", GTK_ALIGN_CENTER,
                    "margin", 6,
                    "xalign", 0.0,
                    NULL);
      gtk_box_pack_start (GTK_BOX (row), label, TRUE, TRUE, 0);
      gdk_rgba_parse (&rgba, colors[i].color);
      swatch = g_object_new (g_type_from_name ("GtkColorSwatch"),
                             "rgba", &rgba,
                             "selectable", FALSE,
                             "halign", GTK_ALIGN_END,
                             "valign", GTK_ALIGN_CENTER,
                             "margin", 6,
                             "height-request", 24,
                             NULL);
      box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
      gtk_container_add (GTK_CONTAINER (box), swatch);
      gtk_box_pack_start (GTK_BOX (row), box, FALSE, FALSE, 0);
      gtk_widget_show_all (row);
      gtk_list_box_insert (GTK_LIST_BOX (widget), row, -1);
      row = gtk_widget_get_parent (row);
      gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), FALSE);
      if (colors[i].title)
        g_object_set_data (G_OBJECT (row), "title", (gpointer)colors[i].title);
    }

  gtk_list_box_invalidate_headers (GTK_LIST_BOX (widget));

  sw = gtk_widget_get_ancestor (widget, GTK_TYPE_SCROLLED_WINDOW);
  g_signal_connect (sw, "edge-overshot", G_CALLBACK (overshot), widget);
}
コード例 #16
0
ファイル: widget-factory.c プロジェクト: Distrotech/gtk
static void
overshot (GtkScrolledWindow *sw, GtkPositionType pos, GtkWidget *widget)
{
  GtkWidget *box, *row, *label, *swatch;
  GdkRGBA rgba;
  const gchar *color;
  gchar *text;
  GtkWidget *silver;
  GtkWidget *gold;

  silver = GTK_WIDGET (g_object_get_data (G_OBJECT (widget), "Silver"));
  gold = GTK_WIDGET (g_object_get_data (G_OBJECT (widget), "Gold"));

  if (pos == GTK_POS_TOP)
    {
      if (silver)
        {
          gtk_container_remove (GTK_CONTAINER (widget), silver);
          g_object_set_data (G_OBJECT (widget), "Silver", NULL);
        }
      if (gold)
        {
          gtk_container_remove (GTK_CONTAINER (widget), gold);
          g_object_set_data (G_OBJECT (widget), "Gold", NULL);
        }

#ifdef HAVE_LIBCANBERRA
      if (silver || gold)
        ca_gtk_play_for_widget (widget, 0, "event.id", "message", NULL); 
#endif

      return;
    }


  if (gold)
    return;
  else if (silver)
    color = "Gold";
  else
    color = "Silver";

  row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20);
  text = g_strconcat ("<b>", color, "</b>", NULL);
  label = gtk_label_new (text);
  g_free (text);
  g_object_set (label,
                "use-markup", TRUE,
                "halign", GTK_ALIGN_START,
                "valign", GTK_ALIGN_CENTER,
                "margin", 6,
                "xalign", 0.0,
                NULL);
  gtk_box_pack_start (GTK_BOX (row), label, TRUE, TRUE, 0);
  gdk_rgba_parse (&rgba, color);
  swatch = g_object_new (g_type_from_name ("GtkColorSwatch"),
                         "rgba", &rgba,
                         "selectable", FALSE,
                         "halign", GTK_ALIGN_END,
                         "valign", GTK_ALIGN_CENTER,
                         "margin", 6,
                         "height-request", 24,
                         NULL);
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_container_add (GTK_CONTAINER (box), swatch);
  gtk_box_pack_start (GTK_BOX (row), box, FALSE, FALSE, 0);
  gtk_widget_show_all (row);
  gtk_list_box_insert (GTK_LIST_BOX (widget), row, -1);
  row = gtk_widget_get_parent (row);
  gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), FALSE);
  g_object_set_data (G_OBJECT (widget), color, row);
#ifdef HAVE_LIBCANBERRA
  ca_gtk_play_for_widget (widget, 0, "event.id", "complete", NULL); 
#endif
}
コード例 #17
0
static void
cc_sharing_panel_setup_media_sharing_dialog (CcSharingPanel *self)
{
  CcSharingPanelPrivate *priv = self->priv;
  gchar **folders, **list;
  GtkWidget *box, *networks, *grid, *w;
  char *path;

  path = g_find_program_in_path ("rygel");
  if (path == NULL)
    {
      gtk_widget_hide (WID ("media-sharing-button"));
      return;
    }
  g_free (path);

  g_signal_connect (WID ("media-sharing-dialog"), "response",
                    G_CALLBACK (cc_sharing_panel_media_sharing_dialog_response),
                    self);

  cc_media_sharing_get_preferences (&folders);

  box = WID ("shared-folders-listbox");
  gtk_list_box_set_header_func (GTK_LIST_BOX (box),
                                cc_list_box_update_header_func, NULL,
                                NULL);
  cc_list_box_setup_scrolling (GTK_LIST_BOX (box), 3);

  list = folders;
  while (list && *list)
    {
      GtkWidget *row;

      row = cc_sharing_panel_new_media_sharing_row (*list, self);
      gtk_list_box_insert (GTK_LIST_BOX (box), row, -1);
      list++;
    }

  gtk_list_box_insert (GTK_LIST_BOX (box),
                       cc_sharing_panel_new_add_media_sharing_row (self), -1);

  cc_list_box_adjust_scrolling (GTK_LIST_BOX (box));

  g_signal_connect (G_OBJECT (box), "row-activated",
                    G_CALLBACK (cc_sharing_panel_add_folder), self);


  g_strfreev (folders);

  networks = cc_sharing_networks_new (self->priv->sharing_proxy, "rygel");
  grid = WID ("grid4");
  gtk_grid_attach (GTK_GRID (grid), networks, 0, 4, 2, 1);
  gtk_widget_show (networks);

  w = cc_sharing_switch_new (networks);
  gtk_header_bar_pack_start (GTK_HEADER_BAR (WID ("media-sharing-headerbar")), w);
  self->priv->media_sharing_switch = w;

  cc_sharing_panel_bind_networks_to_label (self, networks,
                                           WID ("media-sharing-status-label"));
}
コード例 #18
0
static void
cc_sharing_panel_add_folder (GtkListBox     *box,
                             GtkListBoxRow  *row,
                             CcSharingPanel *self)
{
  CcSharingPanelPrivate *priv = self->priv;
  GtkWidget *dialog;
  gchar *folder;
  gboolean matching = FALSE;
  GList *rows, *l;

  if (!GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row), "is-add")))
    return;

  dialog = gtk_file_chooser_dialog_new (_("Choose a Folder"),
                                        GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (box))),
                                        GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
                                        _("_Cancel"), GTK_RESPONSE_CANCEL,
                                        _("_Open"), GTK_RESPONSE_ACCEPT,
                                        NULL);
  gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), FALSE);
  gtk_dialog_run (GTK_DIALOG (dialog));

  gtk_widget_hide (dialog);

  box = GTK_LIST_BOX (WID ("shared-folders-listbox"));
  rows = gtk_container_get_children (GTK_CONTAINER (box));

  folder = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
  if (!folder || g_str_equal (folder, ""))
    goto bail;

  g_debug ("Trying to add %s", folder);

  for (l = rows; l != NULL; l = l->next)
    {
      const char *string;

      string = g_object_get_data (G_OBJECT (l->data), "path");
      matching = (g_strcmp0 (string, folder) == 0);

      if (matching)
        {
          g_debug ("Found a duplicate for %s", folder);
          break;
        }
    }

  if (!matching)
    {
      GtkWidget *row;
      int i;

      row = cc_sharing_panel_new_media_sharing_row (folder, self);
      i = g_list_length (rows);
      gtk_list_box_insert (GTK_LIST_BOX (box), row, i - 1);
    }
  cc_list_box_adjust_scrolling (GTK_LIST_BOX (box));

bail:
  g_free (folder);
  gtk_widget_destroy (dialog);
}