Beispiel #1
0
/**
 * 显示信息/文件接收UI(是否显示信息或文件接收).
 *
 */
void DialogPeer::ShowInfoEnclosure(DialogPeer *dlgpr)
{
    PalInfo *palinfor;
    GtkTreeModel *mdltorcv,*mdlrcvd,*mdltmp;
    GSList *ecslist;
    GtkWidget *widget,*hpaned,*pbar;
    float progress;
    GdkPixbuf *pixbuf, *rpixbuf, *dpixbuf;
    FileInfo *file;
    gchar *filesize,*path;
    char progresstip[MAX_BUFLEN];
    GtkTreeIter iter;
    gint receiving;//标记是不是窗口在正传送文件时被关闭,又打开的。

    receiving = 0;
    /* 获取文件图标 */
    rpixbuf = obtain_pixbuf_from_stock(GTK_STOCK_FILE);
    dpixbuf = obtain_pixbuf_from_stock(GTK_STOCK_DIRECTORY);

    //设置界面显示
    palinfor = (PalInfo *)(dlgpr->grpinf->member->data);
    mdltorcv = (GtkTreeModel*)g_datalist_get_data(&(dlgpr->mdlset), "file-to-receive-model");
    gtk_list_store_clear(GTK_LIST_STORE(mdltorcv));
    mdlrcvd = (GtkTreeModel*)g_datalist_get_data(&(dlgpr->mdlset), "file-received-model");
    gtk_list_store_clear(GTK_LIST_STORE(mdlrcvd));
    ecslist = cthrd.GetPalEnclosure(palinfor);
    if(ecslist) {
        //只要有该好友的接收文件信息(不分待接收和未接收),就显示
        hpaned = GTK_WIDGET(g_datalist_get_data(&(dlgpr->widset), "main-paned"));
        widget = GTK_WIDGET(g_datalist_get_data(&(dlgpr->widset), "info-frame"));
        gtk_widget_hide(widget);
        widget = GTK_WIDGET(g_datalist_get_data(&(dlgpr->widset),"file-enclosure-frame-widget"));
        gtk_paned_pack2(GTK_PANED(hpaned), widget, FALSE, TRUE);
        widget = GTK_WIDGET(g_datalist_get_data(&(dlgpr->widset),"file-receive-paned-widget"));
        gtk_widget_show(widget);
        //将从中心节点取到的数据向附件接收列表填充
        dlgpr->torcvsize = 0;
        while (ecslist) {
                file = (FileInfo *)ecslist->data;
                filesize = numeric_to_size(file->filesize);
                switch (GET_MODE(file->fileattr)) {
                case IPMSG_FILE_REGULAR:
                        pixbuf = rpixbuf;
                        break;
                case IPMSG_FILE_DIR:
                        pixbuf = dpixbuf;
                        break;
                default:
                        pixbuf = NULL;
                        break;
                }
                if(file->finishedsize < file->filesize) {
                    file->filepath = ipmsg_get_filename_me(file->filepath,&path);
                    if(file->finishedsize > 0)
                        receiving += 1;
                    mdltmp = mdltorcv;
                    dlgpr->torcvsize += file->filesize;
                } else
                    mdltmp = mdlrcvd;
                gtk_list_store_append(GTK_LIST_STORE(mdltmp), &iter);
                gtk_list_store_set(GTK_LIST_STORE(mdltmp), &iter, 0, pixbuf,
                                 1, file->fileown->name, 2, file->filepath,
                                 3, filesize, 5,file, -1);
                g_free(filesize);
                ecslist = g_slist_next(ecslist);
        }
        g_slist_free(ecslist);
        //设置进度条,如果接收完成重新载入待接收和已接收列表
        if(dlgpr->torcvsize == 0) {
            progress = 0;
            snprintf(progresstip, MAX_BUFLEN,_("Receiving Progress."));
        } else {
            if(dlgpr->rcvdsize == 0)
                 snprintf(progresstip, MAX_BUFLEN,_("%s to Receive."),
                          numeric_to_size(dlgpr->torcvsize));
            else {
                progress = percent(dlgpr->rcvdsize,dlgpr->torcvsize)/100;
                snprintf(progresstip, MAX_BUFLEN, _("%s Of %s Received."),
                         numeric_to_size(dlgpr->rcvdsize),numeric_to_size(dlgpr->torcvsize));
            }
        }
        if(progress == 1.0){
                g_source_remove(dlgpr->timerrcv);
                snprintf(progresstip, MAX_BUFLEN,_("Mission Completed!"));
        }
        pbar = GTK_WIDGET(g_datalist_get_data(&(dlgpr->widset),
                                              "file-receive-progress-bar-widget"));
        gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pbar),progress);
        gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pbar),progresstip);
    }  else {
        widget = GTK_WIDGET(g_datalist_get_data(&(dlgpr->widset),
                                                "file-receive-paned-widget"));
        gtk_widget_hide(widget);
    }

    /* 释放文件图标 */
    if (rpixbuf)
            g_object_unref(rpixbuf);
    if (dpixbuf)
            g_object_unref(dpixbuf);

    if(receiving > 0)
        dlgpr->ReceiveFile(dlgpr);
}
void
ags_automation_editor_init(AgsAutomationEditor *automation_editor)
{
  GtkTable *table;
  GtkHPaned *paned;
  GtkScrolledWindow *scrolled_window;
  GtkNotebook *notebook;
  
  table = gtk_table_new(2,
			2,
			FALSE);
  gtk_box_pack_start(GTK_BOX(automation_editor),
		     GTK_WIDGET(table),
		     TRUE, TRUE,
		     0);

  automation_editor->automation_toolbar = ags_automation_toolbar_new();
  gtk_table_attach(table,
		   GTK_WIDGET(automation_editor->automation_toolbar),
		   0, 2,
		   0, 1,
		   GTK_FILL, 0,
		   0, 0);

  paned = (GtkHPaned *) gtk_hpaned_new();
  gtk_table_attach(table,
		   GTK_WIDGET(paned),
		   0, 2,
		   1, 2,
		   GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND,
		   0, 0);

  /* machine selector */
  scrolled_window = (GtkScrolledWindow *) gtk_scrolled_window_new(NULL, NULL);
  gtk_paned_pack1((GtkPaned *) paned,
		  (GtkWidget *) scrolled_window,
		  FALSE, TRUE);

  automation_editor->machine_selector = ags_machine_selector_new();
  gtk_scrolled_window_add_with_viewport(scrolled_window,
					(GtkWidget *) automation_editor->machine_selector);

  automation_editor->selected_machine = NULL;

  /**/
  notebook = gtk_notebook_new();
  gtk_paned_pack2((GtkPaned *) paned,
		  (GtkWidget *) notebook,
		  TRUE, FALSE);
  
  /* notebook and automation edit */
  /* audio */
  automation_editor->audio_table = (GtkTable *) gtk_table_new(4, 3, FALSE);
  gtk_notebook_append_page(notebook,
			   automation_editor->audio_table,
			   gtk_label_new("audio\0"));
  
  automation_editor->audio_automation_edit = NULL;

  /* output */
  automation_editor->output_table = (GtkTable *) gtk_table_new(4, 3, FALSE);
  gtk_notebook_append_page(notebook,
			   automation_editor->output_table,
			   gtk_label_new("output\0"));

  automation_editor->output_automation_edit = NULL;
  automation_editor->output_notebook = ags_notebook_new();
  automation_editor->output_notebook->flags |= (AGS_NOTEBOOK_SHOW_INPUT);
  gtk_table_attach(automation_editor->output_table,
		   (GtkWidget *) automation_editor->output_notebook,
		   0, 3,
		   0, 1,
		   GTK_FILL|GTK_EXPAND,
		   GTK_FILL,
		   0, 0);

  /* input */
  automation_editor->input_table = (GtkTable *) gtk_table_new(4, 3, FALSE);
  gtk_notebook_append_page(notebook,
			   automation_editor->input_table,
			   gtk_label_new("input\0"));

  automation_editor->input_automation_edit = NULL;
  automation_editor->input_notebook = ags_notebook_new();
  automation_editor->input_notebook->flags |= (AGS_NOTEBOOK_SHOW_INPUT);
  gtk_table_attach(automation_editor->input_table,
		   (GtkWidget *) automation_editor->input_notebook,
		   0, 3,
		   0, 1,
		   GTK_FILL|GTK_EXPAND,
		   GTK_FILL,
		   0, 0);
}
Beispiel #3
0
static void
create_calendar(void)
{
  static CalendarData calendar_data;

  GtkWidget *window, *hpaned, *vbox, *rpane, *hbox;
  GtkWidget *calendar, *toggle, *scroller, *button;
  GtkWidget *frame, *label, *bbox, *align, *details;

  GtkSizeGroup *size;
  GtkStyle *style;
  gchar *font;
  gint i;
  
  struct {
    gboolean init;
    char *label;
  } flags[] =
    {
      { TRUE,  "Show _Heading" },
      { TRUE,  "Show Day _Names" },
      { FALSE, "No Month _Change" },
      { TRUE,  "Show _Week Numbers" },
      { FALSE, "Week Start _Monday" },
      { TRUE,  "Show De_tails" },
    };

  calendar_data.window = NULL;
  calendar_data.font_dialog = NULL;
  calendar_data.details_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);

  for (i = 0; i < G_N_ELEMENTS (calendar_data.settings); i++)
    calendar_data.settings[i] = 0;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "GtkCalendar Example");
  gtk_container_set_border_width (GTK_CONTAINER (window), 12);
  g_signal_connect (window, "destroy",
		    G_CALLBACK (gtk_main_quit),
		    NULL);
  g_signal_connect (window, "delete-event",
		    G_CALLBACK (gtk_false),
		    NULL);

  hpaned = gtk_hpaned_new ();

  /* Calendar widget */
  calendar = lunar_calendar_new ();
  calendar_data.calendar_widget = calendar;
  frame = create_frame ("<b>Calendar</b>", calendar, 0, 0);
  gtk_paned_pack1 (GTK_PANED (hpaned), frame, TRUE, FALSE);

  calendar_data.window = calendar;
  calendar_set_flags(&calendar_data);
  gtk_calendar_mark_day (GTK_CALENDAR (calendar), 19);	

  g_signal_connect (calendar, "month_changed", 
		    G_CALLBACK (calendar_month_changed),
		    &calendar_data);
  g_signal_connect (calendar, "day_selected", 
		    G_CALLBACK (calendar_day_selected),
		    &calendar_data);
  g_signal_connect (calendar, "day_selected_double_click", 
		    G_CALLBACK (calendar_day_selected_double_click),
		    &calendar_data);
  g_signal_connect (calendar, "prev_month", 
		    G_CALLBACK (calendar_prev_month),
		    &calendar_data);
  g_signal_connect (calendar, "next_month", 
		    G_CALLBACK (calendar_next_month),
		    &calendar_data);
  g_signal_connect (calendar, "prev_year", 
		    G_CALLBACK (calendar_prev_year),
		    &calendar_data);
  g_signal_connect (calendar, "next_year", 
		    G_CALLBACK (calendar_next_year),
		    &calendar_data);

  rpane = gtk_vbox_new (FALSE, DEF_PAD_SMALL);
  gtk_paned_pack2 (GTK_PANED (hpaned), rpane, FALSE, FALSE);

  /* Build the right font-button */

  vbox = gtk_vbox_new(FALSE, DEF_PAD_SMALL);
  frame = create_frame ("<b>Options</b>", vbox, 1, 0);
  gtk_box_pack_start (GTK_BOX (rpane), frame, FALSE, TRUE, 0);
  size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

  gtk_widget_ensure_style (calendar);
  style = gtk_widget_get_style (calendar);
  font = pango_font_description_to_string (style->font_desc);
  button = gtk_font_button_new_with_font (font);
  g_free (font);

  g_signal_connect (button, "font-set",
                    G_CALLBACK(calendar_select_font),
                    &calendar_data);

  label = gtk_label_new_with_mnemonic ("_Font:");
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_size_group_add_widget (size, label);

  hbox = gtk_hbox_new (FALSE, DEF_PAD_SMALL);
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);

  /* Color button */
  GdkColor color;
  gdk_color_parse("red", &color);

  button = gtk_color_button_new_with_color(&color);
  lunar_calendar_set_jieri_color(LUNAR_CALENDAR(calendar), &color);
  g_signal_connect (button, "color-set", G_CALLBACK(calendar_select_color), &calendar_data);

  label = gtk_label_new_with_mnemonic ("Holiday _Color:");
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_size_group_add_widget (size, label);

  hbox = gtk_hbox_new (FALSE, DEF_PAD_SMALL);
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
  /* Build the width entry */

  button = gtk_spin_button_new_with_range (0, 127, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (button),
                             gtk_calendar_get_detail_width_chars (GTK_CALENDAR (calendar)));

  g_signal_connect (button, "value-changed",
                    G_CALLBACK (detail_width_changed),
                    &calendar_data);

  label = gtk_label_new_with_mnemonic ("Details W_idth:");
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_size_group_add_widget (size, label);

  hbox = gtk_hbox_new (FALSE, DEF_PAD_SMALL);
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);

  /* Build the height entry */

  button = gtk_spin_button_new_with_range (0, 127, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (button),
                             gtk_calendar_get_detail_height_rows (GTK_CALENDAR (calendar)));

  g_signal_connect (button, "value-changed",
                    G_CALLBACK (detail_height_changed),
                    &calendar_data);

  label = gtk_label_new_with_mnemonic ("Details H_eight:");
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_size_group_add_widget (size, label);

  hbox = gtk_hbox_new (FALSE, DEF_PAD_SMALL);
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);

#if 0
  /* Build the right details frame */

  vbox = gtk_vbox_new(FALSE, DEF_PAD_SMALL);
  frame = create_frame ("<b>Details</b>", vbox, 1, 1);
  gtk_box_pack_start (GTK_BOX (rpane), frame, FALSE, TRUE, 0);

  details = gtk_text_view_new();
  calendar_data.details_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (details));

  calendar_data.details_changed = g_signal_connect (calendar_data.details_buffer, "changed",
                                                    G_CALLBACK (calendar_details_changed),
                                                    &calendar_data);

  scroller = gtk_scrolled_window_new (NULL, NULL);
  gtk_container_add (GTK_CONTAINER (scroller), details);

  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroller),
                                       GTK_SHADOW_IN);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroller),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);

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

  hbox = gtk_hbox_new (FALSE, DEF_PAD_SMALL);
  align = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
  gtk_container_add (GTK_CONTAINER (align), hbox);
  gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, TRUE, 0);

  button = gtk_button_new_with_mnemonic ("Demonstrate _Details");

  g_signal_connect_swapped (button,
                            "clicked",
                            G_CALLBACK (demonstrate_details),
                            &calendar_data);

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

  button = gtk_button_new_with_mnemonic ("_Reset Details");

  g_signal_connect_swapped (button,
                            "clicked",
                            G_CALLBACK (reset_details),
                            &calendar_data);

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

  toggle = gtk_check_button_new_with_mnemonic ("_Use Details");
  g_signal_connect (toggle, "toggled",
                    G_CALLBACK(calendar_toggle_details),
                    &calendar_data);
  gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, TRUE, 0);
#endif
  
  /* Build the Right frame with the flags in */ 

  vbox = gtk_vbox_new(FALSE, 0);
  frame = create_expander ("<b>Flags</b>", vbox, 1, 0);
  gtk_box_pack_start (GTK_BOX (rpane), frame, TRUE, TRUE, 0);

  for (i = 0; i < G_N_ELEMENTS (calendar_data.settings); i++)
    {
      toggle = gtk_check_button_new_with_mnemonic(flags[i].label);
      gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, TRUE, 0);
      calendar_data.flag_checkboxes[i] = toggle;

      g_signal_connect (toggle, "toggled",
                        G_CALLBACK (calendar_toggle_flag),
			&calendar_data);

      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), flags[i].init);
    }

  /*
   *  Build the Signal-event part.
   */

  vbox = gtk_vbox_new (TRUE, DEF_PAD_SMALL);
  frame = create_frame ("<b>Signal Events</b>", vbox, 1, 0);
  
  hbox = gtk_hbox_new (FALSE, 3);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
  label = gtk_label_new ("Signal:");
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
  calendar_data.last_sig = gtk_label_new ("");
  gtk_box_pack_start (GTK_BOX (hbox), calendar_data.last_sig, FALSE, TRUE, 0);

  hbox = gtk_hbox_new (FALSE, 3);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
  label = gtk_label_new ("Previous signal:");
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
  calendar_data.prev_sig = gtk_label_new ("");
  gtk_box_pack_start (GTK_BOX (hbox), calendar_data.prev_sig, FALSE, TRUE, 0);

  hbox = gtk_hbox_new (FALSE, 3);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
  label = gtk_label_new ("Second previous signal:");
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
  calendar_data.prev2_sig = gtk_label_new ("");
  gtk_box_pack_start (GTK_BOX (hbox), calendar_data.prev2_sig, FALSE, TRUE, 0);

  /*
   *  Glue everything together
   */

  bbox = gtk_hbutton_box_new ();
  gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);

  button = gtk_button_new_with_label ("Close");
  g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL);
  gtk_container_add (GTK_CONTAINER (bbox), button);

  vbox = gtk_vbox_new (FALSE, DEF_PAD_SMALL);

  gtk_box_pack_start (GTK_BOX (vbox), hpaned,                TRUE,  TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), frame,                 FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), bbox,                  FALSE, TRUE, 0);

  gtk_container_add (GTK_CONTAINER (window), vbox);

  //GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
  gtk_widget_grab_default (button);

  gtk_window_set_default_size (GTK_WINDOW (window), 600, 0);
  gtk_widget_show_all (window);
}
static GtkWidget *
gnc_plugin_page_sx_list_create_widget (GncPluginPage *plugin_page)
{
    GncPluginPageSxList *page;
    GncPluginPageSxListPrivate *priv;
    GtkWidget *widget;
    GtkWidget *vbox;
    GtkWidget *label;
    GtkWidget *swin;
    char *markup;
    char *text;

    page = GNC_PLUGIN_PAGE_SX_LIST(plugin_page);
    priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(page);
    if (priv->widget != NULL)
        return priv->widget;

    /* Create Vpaned widget for top level */
    widget = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
    priv->widget = widget;
    gtk_widget_show (priv->widget);

    // Set the style context for this page so it can be easily manipulated with css
    gnc_widget_set_style_context (GTK_WIDGET(priv->widget), "GncSxPage");

    /* Add vbox and label */
    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);
    gtk_paned_pack1( GTK_PANED(widget), vbox, TRUE, FALSE);

    label = gtk_label_new(NULL);
    text = g_strdup_printf(_("Transactions"));
    markup = g_markup_printf_escaped ("<b> %s</b>", text);
    gtk_label_set_markup (GTK_LABEL (label), markup);
    g_free (markup);
    g_free (text);
    gnc_label_set_alignment (label, 0.0, 0);
    gtk_widget_show (label);
    gtk_box_pack_start ( GTK_BOX(vbox), label, FALSE, FALSE, 0);
    gtk_widget_show (vbox);

    /* Create scrolled window for top area */
    swin = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start ( GTK_BOX(vbox), swin, TRUE, TRUE, 5);
    gtk_widget_show (swin);

    {
        // gint half_way;
        // half_way = plugin_page->notebook_page->allocation.height * 0.5;
        // fixme; get a real value:
        gtk_paned_set_position(GTK_PANED(priv->widget), 160);
    }

    {
        GDate end;
        g_date_clear(&end, 1);
        gnc_gdate_set_today (&end);
        g_date_add_years(&end, 1);
        priv->instances = GNC_SX_INSTANCE_MODEL(gnc_sx_get_instances(&end, TRUE));
    }

    {
        GtkAction *edit_action, *delete_action;
        edit_action = gnc_plugin_page_get_action(GNC_PLUGIN_PAGE(page), "SxListEditAction");
        delete_action = gnc_plugin_page_get_action(GNC_PLUGIN_PAGE(page), "SxListDeleteAction");
        gtk_action_set_sensitive(edit_action, FALSE);
        gtk_action_set_sensitive(delete_action, FALSE);
    }

    {
        GtkTreeSelection *selection;

        priv->tree_view = GTK_TREE_VIEW(gnc_tree_view_sx_list_new(priv->instances));
        g_object_set(G_OBJECT(priv->tree_view),
                     "state-section", STATE_SECTION,
                     "show-column-menu", TRUE,
                     NULL);
        gtk_container_add(GTK_CONTAINER( swin ), GTK_WIDGET(priv->tree_view));

        selection = gtk_tree_view_get_selection(priv->tree_view);
        gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
        g_signal_connect(G_OBJECT(selection), "changed", (GCallback)gppsl_selection_changed_cb, (gpointer)page);
        g_signal_connect(G_OBJECT(priv->tree_view), "row-activated", (GCallback)gppsl_row_activated_cb, (gpointer)page);
    }

    /* Add vbox and label */
    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);;
    gtk_paned_pack2( GTK_PANED(widget), vbox, TRUE, FALSE);

    label = gtk_label_new(NULL);
    text = g_strdup_printf(_("Upcoming Transactions"));
    markup = g_markup_printf_escaped ("<b> %s</b>", text);
    gtk_label_set_markup (GTK_LABEL (label), markup);
    g_free (markup);
    g_free (text);
    gnc_label_set_alignment (label, 0.0, 0);
    gtk_widget_show (label);

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

    /* Create scrolled window for bottom area */
    swin = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start ( GTK_BOX(vbox), swin, TRUE, TRUE, 5);
    gtk_widget_show (swin);

    {
        priv->dense_cal_model = gnc_sx_instance_dense_cal_adapter_new(GNC_SX_INSTANCE_MODEL(priv->instances));
        priv->gdcal = GNC_DENSE_CAL(gnc_dense_cal_new_with_model(GNC_DENSE_CAL_MODEL(priv->dense_cal_model)));
        g_object_ref_sink(priv->gdcal);

        gnc_dense_cal_set_months_per_col(priv->gdcal, 4);
        gnc_dense_cal_set_num_months(priv->gdcal, 12);

        gtk_container_add (GTK_CONTAINER(swin), GTK_WIDGET(priv->gdcal));
    }

    priv->gnc_component_id = gnc_register_gui_component("plugin-page-sx-list",
                             gnc_plugin_page_sx_list_refresh_cb,
                             gnc_plugin_page_sx_list_close_cb,
                             page);
    gnc_gui_component_set_session (priv->gnc_component_id,
                                   gnc_get_current_session());

    return priv->widget;
}
Beispiel #5
0
int main( int argc, char **argv ) {
  gtk_init( &argc, &argv );
  GtkWidget *window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
  gtk_window_set_title( GTK_WINDOW( window ), "Using Multiple Containers" );
  gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
  gtk_widget_set_size_request( window, 640, 480 );

  GtkWidget *notebook = gtk_notebook_new();
  GtkWidget *one = gtk_label_new( "One" );
  GtkWidget *two = gtk_label_new( "Two" );
  GtkWidget *three = gtk_label_new( "Three" );
  GtkWidget *four = gtk_label_new( "Four" );
  GtkWidget *tag1 = gtk_label_new( "This is page one" );
  GtkWidget *tag2 = gtk_label_new( "This is page TWO" );
  GtkWidget *tag3 = gtk_label_new( "This is page THree" );
  GtkWidget *tag4 = gtk_label_new( "This is page FouR" );
  GtkWidget *next = gtk_button_new_with_label( "Next" );
  GtkWidget *prev = gtk_button_new_with_label( "Prev" );
  GtkWidget *exit = gtk_button_new_with_label( "Exit" );
  GtkWidget *vpane = gtk_vpaned_new();
  GtkWidget *hbox = gtk_hbox_new( TRUE, 10 );
  GtkWidget *nvbox1 = gtk_vbox_new( TRUE, 5 );
  GtkWidget *nvbox2 = gtk_vbox_new( TRUE, 5 );
  GtkWidget *nvbox3 = gtk_vbox_new( TRUE, 5 );
  GtkWidget *nvbox4 = gtk_vbox_new( TRUE, 5 );
  GtkWidget *expander = gtk_expander_new_with_mnemonic( "click here to show _Next button" );

  gtk_container_add( GTK_CONTAINER( expander ), next );
  gtk_expander_set_expanded( GTK_EXPANDER( expander ), TRUE );
  g_signal_connect( G_OBJECT( next ), "clicked", G_CALLBACK( next_pressed ), (gpointer) notebook );
  gtk_box_pack_start( GTK_BOX( nvbox1 ), tag1, FALSE, FALSE, 5 );
  gtk_box_pack_start( GTK_BOX( nvbox1 ), expander, FALSE, FALSE, 5 );
  expander = gtk_expander_new_with_mnemonic( "click here to show _Next button" );
  gtk_expander_set_expanded( GTK_EXPANDER( expander ), TRUE );
  next = gtk_button_new_with_label( "Next" );
  g_signal_connect( G_OBJECT( next ), "clicked", G_CALLBACK( next_pressed ), (gpointer) notebook );
  gtk_container_add( GTK_CONTAINER( expander ), next );
  gtk_box_pack_start( GTK_BOX( nvbox2 ), tag2, FALSE, FALSE, 5 );
  gtk_box_pack_start( GTK_BOX( nvbox2 ), expander, FALSE, FALSE, 5 );
  expander = gtk_expander_new_with_mnemonic( "click here to show _Next button" );
  gtk_expander_set_expanded( GTK_EXPANDER( expander ), TRUE );
  next = gtk_button_new_with_label( "Next" );
  g_signal_connect( G_OBJECT( next ), "clicked", G_CALLBACK( next_pressed ), (gpointer) notebook );
  gtk_container_add( GTK_CONTAINER( expander ), next );
  gtk_box_pack_start( GTK_BOX( nvbox3 ), tag3, FALSE, FALSE, 5 );
  gtk_box_pack_start( GTK_BOX( nvbox3 ), expander, FALSE, FALSE, 5 );
  expander = gtk_expander_new_with_mnemonic( "click here to show _Next button" );
  gtk_expander_set_expanded( GTK_EXPANDER( expander ), TRUE );
  next = gtk_button_new_with_label( "Next" );
  g_signal_connect( G_OBJECT( next ), "clicked", G_CALLBACK( next_pressed ), (gpointer) notebook );
  gtk_container_add( GTK_CONTAINER( expander ), next );
  gtk_box_pack_start( GTK_BOX( nvbox4 ), tag4, FALSE, FALSE, 5 );
  gtk_box_pack_start( GTK_BOX( nvbox4 ), expander, FALSE, FALSE, 5 );


  gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), nvbox1, one );
  gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), nvbox2, two );
  gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), nvbox3, three );
  gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), nvbox4, four );
  gtk_notebook_set_tab_pos( GTK_NOTEBOOK( notebook ), GTK_POS_TOP );
  gtk_notebook_set_show_tabs( GTK_NOTEBOOK( notebook ), TRUE );

  g_signal_connect( G_OBJECT( prev ), "clicked", G_CALLBACK( prev_pressed ), (gpointer) notebook );
  g_signal_connect( G_OBJECT( exit ), "clicked", G_CALLBACK( exit_pressed ), NULL );

  gtk_box_pack_end( GTK_BOX( hbox ), exit, TRUE, FALSE, 5 );
  gtk_box_pack_end( GTK_BOX( hbox ), prev, TRUE, FALSE, 5 );

  gtk_paned_pack1( GTK_PANED( vpane ), notebook, TRUE, FALSE );
  gtk_paned_pack2( GTK_PANED( vpane ), hbox, TRUE, FALSE );

  g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy ), NULL );
  gtk_container_add( GTK_CONTAINER( window ), vpane );
  gtk_widget_show_all( window );
  gtk_main();
  return 0;
}
Beispiel #6
0
int main(int argc, char ** argv)
{
  GtkWidget * vbox;
  GtkWidget * hpaned;
  GtkWidget * sc_win, * sc_buffer;
  GtkWidget * menu_bar;
  GtkWidget * file_menu, * file_item;
  GtkWidget * generate_menu, * generate_item;
  GtkWidget * settings_menu, * settings_item;
  
  GtkWidget * zoom_box, * zoom_button;
  int i;

  //init general
  colors = (color_t *)malloc(NUM_COLORS * sizeof(color_t));
  oldcolors = (color_t *)malloc(OLD_NUM_COLORS * sizeof(color_t));
  memset(mdata, 0, BUFFER_COUNT * sizeof(unsigned char *));
  memset(icons, 0, BUFFER_COUNT * sizeof(GtkWidget *));
  memset(icon_event_boxes, 0, BUFFER_COUNT * sizeof(GtkWidget *));
  mdata[current_buffer] = (unsigned char *)malloc(128 * 128);
  
  load_colors_plain(colors, "colors");
  load_colors_plain(oldcolors, "oldcolors");
  newcolors = colors;
  
  //save_colors(colors, "colors.bin");
  //load_colors(colors, "colors.bin");
  
  srand(time(NULL));
  
  config = config_new();
  
  //init gtk
  gtk_init(&argc, &argv);
  
  //window
  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "ImageToMap X v" VERSION_NUMBER);
  g_signal_connect(window, "delete_event", G_CALLBACK(kill_window), NULL);
  
  //vbox
#ifdef GTK2
  vbox = gtk_vbox_new(FALSE, 0);
#else
  vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#endif
  gtk_frame_set_shadow_type(GTK_FRAME(vbox), GTK_SHADOW_IN);
  gtk_container_add(GTK_CONTAINER (window), vbox);
  gtk_widget_show(vbox);
  
  //////menu_bar
  menu_bar = gtk_menu_bar_new();
  gtk_box_pack_start(GTK_BOX(vbox), menu_bar, FALSE, TRUE, 0);
  gtk_widget_show(menu_bar);
  
  ////////file_menu
  file_menu = gtk_menu_new();
  
  //////////file_menu items
  construct_tool_bar_add(file_menu, "Open", ITEM_SIGNAL_OPEN);
  construct_tool_bar_add(file_menu, "Open Grid Image", ITEM_SIGNAL_OPEN_GRID_IMAGE);
  construct_tool_bar_add(file_menu, "Save", ITEM_SIGNAL_SAVE);
  construct_tool_bar_add(file_menu, "Save Increment", ITEM_SIGNAL_SAVE_INCREMENT);
  construct_tool_bar_add(file_menu, "Save All", ITEM_SIGNAL_SAVE_ALL);
  construct_tool_bar_add(file_menu, "Save Raw Map", ITEM_SIGNAL_SAVE_RM);
  construct_tool_bar_add(file_menu, "Export Image", ITEM_SIGNAL_EXPORT_IMAGE);
  /* construct_tool_bar_add_deactivate(file_menu, "Render World", ITEM_SIGNAL_WORLD_RENDER_ITEM); */
  construct_tool_bar_add(file_menu, "Render World", ITEM_SIGNAL_WORLD_RENDER_ITEM);
  construct_tool_bar_add(file_menu, "Clean Buffer List", ITEM_SIGNAL_CLEAN);
  construct_tool_bar_add(file_menu, "Quit", ITEM_SIGNAL_QUIT);
	
  /////////file_item
  file_item = gtk_menu_item_new_with_label("File");
  gtk_widget_show(file_item);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file_item), file_menu);
  gtk_menu_shell_append((GtkMenuShell *)menu_bar, file_item);
  
  ////////generate_menu
  generate_menu = gtk_menu_new();
	
  //////////generate_menu items
  construct_tool_bar_add(generate_menu, "Mandelbrot", ITEM_SIGNAL_GENERATE_MANDELBROT);
  construct_tool_bar_add(generate_menu, "Julia", ITEM_SIGNAL_GENERATE_JULIA);
  construct_tool_bar_add(generate_menu, "Palette", ITEM_SIGNAL_GENERATE_PALETTE);
  construct_tool_bar_add(generate_menu, "Random Noise", ITEM_SIGNAL_GENERATE_RANDOM_NOISE);
   construct_tool_bar_add(generate_menu, "From Clipboard", ITEM_SIGNAL_GENERATE_FROM_CLIPBOARD);
   
  /////////generate_item
  generate_item = gtk_menu_item_new_with_label("Generate");
  gtk_widget_show(generate_item);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(generate_item), generate_menu);
  gtk_menu_shell_append((GtkMenuShell *)menu_bar, generate_item);

  ////////settings_menu
  settings_menu = gtk_menu_new();
  
  ////////settings_item
  settings_item = gtk_menu_item_new_with_label("Settings");
  gtk_widget_show(settings_item);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(settings_item), settings_menu);
  gtk_menu_shell_append((GtkMenuShell *)menu_bar, settings_item);

  //////////FSD_checkbox
  FSD_checkbox = gtk_check_menu_item_new_with_label("Floyd–Steinberg dithering");
  gtk_menu_shell_append(GTK_MENU_SHELL(settings_menu), FSD_checkbox);
  gtk_widget_show(FSD_checkbox);

  //////////YUV_checkbox
  YUV_checkbox = gtk_check_menu_item_new_with_label("YUV color conversion");
  gtk_menu_shell_append(GTK_MENU_SHELL(settings_menu), YUV_checkbox);
  gtk_widget_show(YUV_checkbox);

  //////////old_colors_checkbox
  old_colors_checkbox = gtk_check_menu_item_new_with_label("Old Colors");
  gtk_menu_shell_append(GTK_MENU_SHELL(settings_menu), old_colors_checkbox);
  gtk_widget_show(old_colors_checkbox);
  g_signal_connect_swapped(old_colors_checkbox, "toggled",
			   G_CALLBACK(old_colors_checkbox_toggle), 0);

  //drop_down_menu
  init_drop_down_menu();

  //hpaned
#ifdef GTK2
  hpaned = gtk_hpaned_new();
#else
  hpaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
#endif
  gtk_widget_set_size_request (hpaned, 220, -1);
  gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0);
  gtk_widget_show(hpaned);

  ////sc_buffer
  sc_buffer = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sc_buffer), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
#ifdef GTK2
  gtk_widget_set_size_request(sc_buffer, 128 + 32, 512);
#else
  gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(sc_buffer), 128 + 32);
  gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(sc_buffer), 512);
#endif
  gtk_paned_pack2(GTK_PANED(hpaned), sc_buffer, FALSE, FALSE);
  gtk_widget_show(sc_buffer);

  //////list_vbox
#ifdef GTK2
  list_vbox = gtk_vbox_new(FALSE, 0);
#else
  list_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#endif
  
#ifdef GTK2
  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sc_buffer), list_vbox);
#else
  gtk_container_add(GTK_CONTAINER(sc_buffer), list_vbox);
#endif
  
  gtk_widget_show(list_vbox);

  ////sc_win
  sc_win = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sc_win), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
#ifdef GTK2
  gtk_widget_set_size_request(sc_win, 128 * 4, 128 * 4);
  gtk_window_resize(GTK_WINDOW(window), 128 * 4 + 200, 128 * 4 + 70);
#else
  gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(sc_win), 128 * 4);
  gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(sc_win), 128 * 4);
#endif
  gtk_paned_pack1(GTK_PANED(hpaned), sc_win, TRUE, FALSE);
  gtk_widget_show(sc_win);
	
  //////image
  dimage = gdk_pixbuf_new_from_file("start.png", NULL);
  image = gtk_image_new();
  gtk_image_set_from_pixbuf(GTK_IMAGE(image), dimage);

#ifdef GTK2
  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sc_win), image);
#else
  gtk_container_add(GTK_CONTAINER(sc_win), image);
#endif
  
  gtk_widget_show(image);
	
  ////zoom_box
#ifdef GTK2
  zoom_box = gtk_hbox_new(FALSE, 0);
#else
  zoom_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#endif
  gtk_box_pack_start(GTK_BOX(vbox), zoom_box, FALSE, FALSE, 0);
  gtk_widget_show(zoom_box);
	
  //////zoom_button (+)
  zoom_button = gtk_button_new_with_label("+");
	
  gtk_box_pack_start(GTK_BOX(zoom_box), zoom_button, TRUE, TRUE, 2);
  g_signal_connect(zoom_button, "clicked", G_CALLBACK(button_click2), "button.zoomp");
  gtk_widget_show(zoom_button);
	
  //////zoom_button (|)
  zoom_button = gtk_button_new_with_label("|");
	
  gtk_box_pack_start(GTK_BOX(zoom_box), zoom_button, TRUE, TRUE, 2);
  g_signal_connect(zoom_button, "clicked", G_CALLBACK(button_click2), "button.zoome");
  gtk_widget_show(zoom_button);
	
  //////zoom_button (-)
  zoom_button = gtk_button_new_with_label("-");
	
  gtk_box_pack_start(GTK_BOX(zoom_box), zoom_button, TRUE, TRUE, 2);
  g_signal_connect(zoom_button, "clicked", G_CALLBACK(button_click2), "button.zoomm");
  gtk_widget_show(zoom_button);
	
  //icon
  gtk_window_set_icon(GTK_WINDOW(window), create_pixbuf("imagetomap.ico"));

  //Drag and drop
  gtk_drag_dest_set(window, GTK_DEST_DEFAULT_ALL, targets, sizeof(targets)/sizeof(*targets), GDK_ACTION_COPY);
  gtk_drag_dest_add_uri_targets(window);
  g_signal_connect(window, "drag-drop", G_CALLBACK(drag_drop), NULL);
  g_signal_connect(window, "drag-motion", G_CALLBACK(drag_motion), NULL);
  g_signal_connect(window, "drag-data-received", G_CALLBACK(drag_received), NULL);
  g_signal_connect(window, "drag-leave", G_CALLBACK(drag_leave), NULL);
  
  //display window
  gtk_widget_show (window);
  gtk_main();
	
  //clean up
  free(colors);
  for(i = 0; i < BUFFER_COUNT; i++)
    free(mdata[i]);
  config_free(config);
	
  return 0;
}
Beispiel #7
0
void
pevent_dialog_show ()
{
	GtkWidget *vbox, *hbox, *tbox, *wid, *bh, *th;
	GtkListStore *store, *hstore;
	GtkTreeSelection *sel;

	if (pevent_dialog)
	{
		mg_bring_tofront (pevent_dialog);
		return;
	}

	pevent_dialog =
			  mg_create_generic_tab ("edit events", _("Edit Events"),
											 TRUE, FALSE, pevent_dialog_close, NULL,
											 600, 455, &vbox, 0);

	wid = gtk_vpaned_new ();
	th = gtk_vbox_new (0, 2);
	bh = gtk_vbox_new (0, 2);
	gtk_widget_show (th);
	gtk_widget_show (bh);
	gtk_paned_pack1 (GTK_PANED (wid), th, 1, 1);
	gtk_paned_pack2 (GTK_PANED (wid), bh, 0, 1);
	gtk_box_pack_start (GTK_BOX (vbox), wid, 1, 1, 0);
	gtk_widget_show (wid);

	store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING,
	                            G_TYPE_STRING, G_TYPE_INT);
	pevent_dialog_list = gtkutil_treeview_new (th, GTK_TREE_MODEL (store), NULL,
															 COL_EVENT_NAME, _("Event"),
															 COL_EVENT_TEXT, _("Text"), -1);
	sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (pevent_dialog_list));
	g_signal_connect (G_OBJECT (sel), "changed",
							G_CALLBACK (pevent_dialog_select), store);

	pevent_dialog_twid = gtk_xtext_new (colors, 0);
	gtk_xtext_set_tint (GTK_XTEXT (pevent_dialog_twid), prefs.hex_text_tint_red, prefs.hex_text_tint_green, prefs.hex_text_tint_blue);
	gtk_xtext_set_background (GTK_XTEXT (pevent_dialog_twid),
									  channelwin_pix, prefs.hex_text_transparent);

	pevent_dialog_entry = gtk_entry_new_with_max_length (255);
	g_signal_connect (G_OBJECT (pevent_dialog_entry), "activate",
							G_CALLBACK (pevent_dialog_update), pevent_dialog_twid);
	gtk_box_pack_start (GTK_BOX (bh), pevent_dialog_entry, 0, 0, 0);
	gtk_widget_show (pevent_dialog_entry);

	tbox = gtk_hbox_new (0, 0);
	gtk_container_add (GTK_CONTAINER (bh), tbox);
	gtk_widget_show (tbox);

	gtk_widget_set_usize (pevent_dialog_twid, 150, 20);
	gtk_container_add (GTK_CONTAINER (tbox), pevent_dialog_twid);
	gtk_xtext_set_font (GTK_XTEXT (pevent_dialog_twid), prefs.hex_text_font);

	wid = gtk_vscrollbar_new (GTK_XTEXT (pevent_dialog_twid)->adj);
	gtk_box_pack_start (GTK_BOX (tbox), wid, FALSE, FALSE, 0);
	show_and_unfocus (wid);

	gtk_widget_show (pevent_dialog_twid);

	hstore = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);
	pevent_dialog_hlist = gtkutil_treeview_new (bh, GTK_TREE_MODEL (hstore),
															  NULL,
															  0, _("$ Number"),
															  1, _("Description"), -1);
	gtk_widget_show (pevent_dialog_hlist);

	pevent_dialog_fill (pevent_dialog_list);
	gtk_widget_show (pevent_dialog_list);

	hbox = gtk_hbutton_box_new ();
	gtk_box_pack_end (GTK_BOX (vbox), hbox, 0, 0, 2);
	/*wid = gtk_button_new_with_label (_("Save"));
	gtk_box_pack_end (GTK_BOX (hbox), wid, 0, 0, 0);
	gtk_signal_connect (GTK_OBJECT (wid), "clicked",
							  GTK_SIGNAL_FUNC (pevent_save_cb), NULL);
	gtk_widget_show (wid);*/
	gtkutil_button (hbox, GTK_STOCK_SAVE_AS, NULL, pevent_save_cb,
						 (void *) 1, _("Save As..."));
	gtkutil_button (hbox, GTK_STOCK_OPEN, NULL, pevent_load_cb,
						 (void *) 0, _("Load From..."));
	wid = gtk_button_new_with_label (_("Test All"));
	gtk_box_pack_end (GTK_BOX (hbox), wid, 0, 0, 0);
	g_signal_connect (G_OBJECT (wid), "clicked",
							G_CALLBACK (pevent_test_cb), pevent_dialog_twid);
	gtk_widget_show (wid);

	wid = gtk_button_new_from_stock (GTK_STOCK_OK);
	gtk_box_pack_start (GTK_BOX (hbox), wid, 0, 0, 0);
	g_signal_connect (G_OBJECT (wid), "clicked",
							G_CALLBACK (pevent_ok_cb), NULL);
	gtk_widget_show (wid);

	gtk_widget_show (hbox);

	gtk_widget_show (pevent_dialog);
}
Beispiel #8
0
/*
 * display the initial menu to setup global options
 * at startup.
 */
static void gtkui_setup(void)
{
   GtkTextIter iter;
   GtkWidget *item, *vbox, *scroll, *vpaned, *logo;
   GtkItemFactory *item_factory;
   GClosure *closure = NULL;
   GdkModifierType mods;
   gint keyval, width, height, left, top;
   char *path = NULL;

   GtkItemFactoryEntry file_menu[] = {
      { "/_File",         "<shift>F",   NULL,             0, "<Branch>" },
      { "/File/_Open",    "<control>O", gtkui_file_open,  0, "<StockItem>", GTK_STOCK_OPEN },
      { "/File/_Save",    "<control>S", gtkui_file_write, 0, "<StockItem>", GTK_STOCK_SAVE },
      { "/File/sep1",     NULL,         NULL,             0, "<Separator>" },
      { "/File/E_xit",    "<control>x", gtkui_exit,       0, "<StockItem>", GTK_STOCK_QUIT },
      { "/_Sniff",        "<shift>S",   NULL,             0, "<Branch>" },
      { "/Sniff/Unified sniffing...",  "<shift>U", gtkui_unified_sniff, 0, "<StockItem>", GTK_STOCK_DND },
      { "/Sniff/Bridged sniffing...",  "<shift>B", gtkui_bridged_sniff, 0, "<StockItem>", GTK_STOCK_DND_MULTIPLE },
      { "/Sniff/sep2",    NULL,         NULL,             0, "<Separator>" },
      { "/Sniff/Set pcap filter...",    "p",       gtkui_pcap_filter,   0, "<StockItem>", GTK_STOCK_PREFERENCES },
      { "/_Options",                    "<shift>O", NULL, 0, "<Branch>" },
      { "/Options/Unoffensive", NULL, toggle_unoffensive, 0, "<ToggleItem>" },
      { "/Options/Promisc mode", NULL, toggle_nopromisc,  0, "<ToggleItem>" },
      { "/Options/Set netmask", "n", gtkui_set_netmask,   0, "<Item>"}
#ifndef OS_WINDOWS
     ,{"/_?",          NULL,         NULL,             0, "<Branch>" },
      {"/?/Contents", " ",           gtkui_help,       0, "<StockItem>", GTK_STOCK_HELP }
#endif
   };
   gint nmenu_items = sizeof (file_menu) / sizeof (file_menu[0]);

   DEBUG_MSG("gtkui_setup");

   width = gtkui_conf_get("window_width");
   height = gtkui_conf_get("window_height");
   left = gtkui_conf_get("window_left");
   top = gtkui_conf_get("window_top");

   /* create menu window */
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title(GTK_WINDOW (window), EC_PROGRAM" "EC_VERSION);
   gtk_window_set_default_size(GTK_WINDOW (window), width, height);

   if(left > 0 || top > 0)
      gtk_window_move(GTK_WINDOW(window), left, top);

   g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtkui_exit), NULL);

   accel_group = gtk_accel_group_new ();
   item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
   gtk_item_factory_create_items (item_factory, nmenu_items, file_menu, NULL);

   /* hidden shortcut to start Unified Sniffing with default interface */
   closure = g_cclosure_new(G_CALLBACK(gtkui_unified_sniff_default), NULL, NULL);
   gtk_accelerator_parse ("u", &keyval, &mods);
   gtk_accel_group_connect(accel_group, keyval, mods, 0, closure);

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

   main_menu = gtk_item_factory_get_widget (item_factory, "<main>");
   gtk_box_pack_start(GTK_BOX(vbox), main_menu, FALSE, FALSE, 0);
   gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
   gtk_widget_show(main_menu);

   if(GBL_PCAP->promisc) {
      /* setting the menu item active will toggle this setting */
      /* it will be TRUE after the menu is updated */
      GBL_PCAP->promisc = 0;
      item = gtk_item_factory_get_item(item_factory, "/Options/Promisc mode");
      gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM (item), TRUE);
   }

   if(GBL_OPTIONS->unoffensive) {
      GBL_OPTIONS->unoffensive = 0;
      item = gtk_item_factory_get_item(item_factory, "/Options/Unoffensive");
      gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM (item), TRUE);
   }

   vpaned = gtk_vpaned_new();

   /* notebook for MDI pages */
   notebook_frame = gtk_frame_new(NULL);
   gtk_frame_set_shadow_type(GTK_FRAME (notebook_frame), GTK_SHADOW_IN);
   gtk_paned_pack1(GTK_PANED(vpaned), notebook_frame, TRUE, TRUE);
   gtk_widget_show(notebook_frame);

   path = INSTALL_DATADIR "/" EC_PROGRAM "/" LOGO_FILE;
   if(g_file_test(path, G_FILE_TEST_EXISTS))
      logo = gtk_image_new_from_file(path);
   else /* if neither path is valid gtk will use a broken image icon */
      logo = gtk_image_new_from_file("./share/" LOGO_FILE);

   gtk_misc_set_alignment (GTK_MISC (logo), 0.5, 0.5);
   gtk_container_add(GTK_CONTAINER (notebook_frame), logo);
   gtk_widget_show(logo);

   /* messages */
   scroll = gtk_scrolled_window_new(NULL, NULL);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scroll),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
   gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);
   gtk_paned_pack2(GTK_PANED (vpaned), scroll, FALSE, TRUE);
   gtk_widget_show(scroll);

   textview = gtk_text_view_new();
   gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW (textview), GTK_WRAP_WORD_CHAR);
   gtk_text_view_set_editable(GTK_TEXT_VIEW (textview), FALSE);
   gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW (textview), FALSE);
   gtk_widget_set_size_request(textview, -1, 140);
   gtk_container_add(GTK_CONTAINER (scroll), textview);
   gtk_widget_show(textview);

   msgbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW (textview));
   gtk_text_buffer_get_end_iter(msgbuffer, &iter);
   endmark = gtk_text_buffer_create_mark(msgbuffer, "end", &iter, FALSE);

   gtk_box_pack_end(GTK_BOX(vbox), vpaned, TRUE, TRUE, 0);
   gtk_widget_show(vpaned);

   gtk_widget_show(window);

   DEBUG_MSG("gtk_setup: end");
}
Beispiel #9
0
static void
rb_grilo_source_constructed (GObject *object)
{
	RBGriloSource *source;
	RBShell *shell;
	RBShellPlayer *shell_player;
	const GList *source_keys;
	GtkTreeViewColumn *column;
	GtkCellRenderer *renderer;
	GtkTreeSelection *selection;
	GtkWidget *scrolled;
	GtkWidget *browserbox;
	GtkWidget *vbox;
	GtkWidget *mainbox;
	GtkAdjustment *adjustment;

	RB_CHAIN_GOBJECT_METHOD (rb_grilo_source_parent_class, constructed, object);
	source = RB_GRILO_SOURCE (object);

	g_object_get (source, "shell", &shell, NULL);
	g_object_get (shell,
		      "db", &source->priv->db,
		      "shell-player", &shell_player,
		      NULL);
	g_object_unref (shell);

	g_object_get (source, "entry-type", &source->priv->entry_type, NULL);

	source->priv->entry_view = rb_entry_view_new (source->priv->db, G_OBJECT (shell_player), TRUE, FALSE);
	g_object_unref (shell_player);
	g_signal_connect (source->priv->entry_view,
			  "notify::sort-order",
			  G_CALLBACK (notify_sort_order_cb),
			  source);

	source_keys = grl_source_supported_keys (source->priv->grilo_source);

	if (g_list_find ((GList *)source_keys, GUINT_TO_POINTER(GRL_METADATA_KEY_TRACK_NUMBER))) {
		rb_entry_view_append_column (source->priv->entry_view, RB_ENTRY_VIEW_COL_TRACK_NUMBER, FALSE);
		source->priv->grilo_keys = g_list_prepend (source->priv->grilo_keys,
							   GUINT_TO_POINTER(GRL_METADATA_KEY_TRACK_NUMBER));
	}

	if (g_list_find ((GList *)source_keys, GUINT_TO_POINTER(GRL_METADATA_KEY_TITLE))) {
		rb_entry_view_append_column (source->priv->entry_view, RB_ENTRY_VIEW_COL_TITLE, TRUE);
		source->priv->grilo_keys = g_list_prepend (source->priv->grilo_keys,
							   GUINT_TO_POINTER(GRL_METADATA_KEY_TITLE));
	}

	if (g_list_find ((GList *)source_keys, GUINT_TO_POINTER(GRL_METADATA_KEY_GENRE))) {
		rb_entry_view_append_column (source->priv->entry_view, RB_ENTRY_VIEW_COL_GENRE, FALSE);
		source->priv->grilo_keys = g_list_prepend (source->priv->grilo_keys,
							   GUINT_TO_POINTER(GRL_METADATA_KEY_GENRE));
	}
	if (g_list_find ((GList *)source_keys, GUINT_TO_POINTER(GRL_METADATA_KEY_ARTIST))) {
		rb_entry_view_append_column (source->priv->entry_view, RB_ENTRY_VIEW_COL_ARTIST, FALSE);
		source->priv->grilo_keys = g_list_prepend (source->priv->grilo_keys,
							   GUINT_TO_POINTER(GRL_METADATA_KEY_ARTIST));
	}
	if (g_list_find ((GList *)source_keys, GUINT_TO_POINTER(GRL_METADATA_KEY_ALBUM))) {
		rb_entry_view_append_column (source->priv->entry_view, RB_ENTRY_VIEW_COL_ALBUM, FALSE);
		source->priv->grilo_keys = g_list_prepend (source->priv->grilo_keys,
							   GUINT_TO_POINTER(GRL_METADATA_KEY_ALBUM));
	}
	/*
	if (g_list_find ((GList *)source_keys, GUINT_TO_POINTER(GRL_METADATA_KEY_DATE))) {
		rb_entry_view_append_column (source->priv->entry_view, RB_ENTRY_VIEW_COL_YEAR, FALSE);
		source->priv->grilo_keys = g_list_prepend (source->priv->grilo_keys,
							   GUINT_TO_POINTER(GRL_METADATA_KEY_DATE));
	}
	*/
	if (g_list_find ((GList *)source_keys, GUINT_TO_POINTER(GRL_METADATA_KEY_DURATION))) {
		rb_entry_view_append_column (source->priv->entry_view, RB_ENTRY_VIEW_COL_DURATION, FALSE);
		source->priv->grilo_keys = g_list_prepend (source->priv->grilo_keys,
							   GUINT_TO_POINTER(GRL_METADATA_KEY_DURATION));
	}

	source->priv->grilo_keys = g_list_prepend (source->priv->grilo_keys, GUINT_TO_POINTER(GRL_METADATA_KEY_CHILDCOUNT));
	source->priv->grilo_keys = g_list_prepend (source->priv->grilo_keys, GUINT_TO_POINTER(GRL_METADATA_KEY_URL));
	source->priv->grilo_keys = g_list_prepend (source->priv->grilo_keys, GUINT_TO_POINTER(GRL_METADATA_KEY_THUMBNAIL));

	/* probably add an image column too? */
	source->priv->browser_model = gtk_tree_store_new (4, GRL_TYPE_MEDIA, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT);
	source->priv->browser_view = gtk_tree_view_new ();
	gtk_tree_view_set_model (GTK_TREE_VIEW (source->priv->browser_view), GTK_TREE_MODEL (source->priv->browser_model));

	column = gtk_tree_view_column_new ();
	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_column_set_title (column, _("Browse"));
	gtk_tree_view_column_pack_start (column, renderer, FALSE);
	gtk_tree_view_column_add_attribute (column, renderer, "text", 1);
	gtk_tree_view_column_set_expand (column, TRUE);
	gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);

	gtk_tree_view_append_column (GTK_TREE_VIEW (source->priv->browser_view), column);
	gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (source->priv->browser_view), TRUE);
	gtk_tree_view_set_expander_column (GTK_TREE_VIEW (source->priv->browser_view), column);
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (source->priv->browser_view), TRUE);
	gtk_tree_view_set_fixed_height_mode (GTK_TREE_VIEW (source->priv->browser_view), TRUE);

	g_signal_connect (source->priv->browser_view, "row-expanded", G_CALLBACK (browser_row_expanded_cb), source);
	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (source->priv->browser_view));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);	/* should be multiple eventually */
	g_signal_connect (selection, "changed", G_CALLBACK (browser_selection_changed_cb), source);

	scrolled = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN);
	adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled));
	g_signal_connect (adjustment, "changed", G_CALLBACK (scroll_adjust_changed_cb), source);
	g_signal_connect (adjustment, "value-changed", G_CALLBACK (scroll_adjust_value_changed_cb), source);

	browserbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);

	/* search bar (if the source supports searching) */
	if (grl_source_supported_operations (source->priv->grilo_source) & GRL_OP_SEARCH) {
		source->priv->search_entry = rb_search_entry_new (FALSE);
		g_object_set (source->priv->search_entry, "explicit-mode", TRUE, NULL);
		g_signal_connect (source->priv->search_entry, "search", G_CALLBACK (search_cb), source);
		g_signal_connect (source->priv->search_entry, "activate", G_CALLBACK (search_cb), source);
		gtk_box_pack_start (GTK_BOX (browserbox), GTK_WIDGET (source->priv->search_entry), FALSE, FALSE, 6);
	}
	gtk_container_add (GTK_CONTAINER (scrolled), source->priv->browser_view);
	gtk_box_pack_start (GTK_BOX (browserbox), scrolled, TRUE, TRUE, 0);

	mainbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	gtk_box_pack_start (GTK_BOX (source), mainbox, TRUE, TRUE, 0);

	/* info bar */
	source->priv->info_bar_label = gtk_label_new ("");
	source->priv->info_bar = gtk_info_bar_new ();
	gtk_info_bar_set_message_type (GTK_INFO_BAR (source->priv->info_bar), GTK_MESSAGE_INFO);
	gtk_info_bar_add_button (GTK_INFO_BAR (source->priv->info_bar), _("Fetch more tracks"), GTK_RESPONSE_OK);
	gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (source->priv->info_bar))),
			   source->priv->info_bar_label);
	gtk_widget_show (GTK_WIDGET (source->priv->info_bar_label));
	gtk_widget_set_no_show_all (GTK_WIDGET (source->priv->info_bar), TRUE);
	g_signal_connect (source->priv->info_bar, "response", G_CALLBACK (fetch_more_cb), source);

	/* don't allow the browser to be hidden? */
	source->priv->paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
	rb_source_bind_settings (RB_SOURCE (source), GTK_WIDGET (source->priv->entry_view), source->priv->paned, NULL);
	gtk_paned_pack1 (GTK_PANED (source->priv->paned), browserbox, FALSE, FALSE);

	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (source->priv->entry_view), TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), source->priv->info_bar, FALSE, FALSE, 0);
	gtk_paned_pack2 (GTK_PANED (source->priv->paned), vbox, TRUE, FALSE);

	gtk_box_pack_start (GTK_BOX (mainbox), source->priv->paned, TRUE, TRUE, 0);

	gtk_widget_show_all (GTK_WIDGET (source));
}
Beispiel #10
0
GtkWidget*
create_windowMain ()
{
	GtkWidget *vbox1;
	GtkWidget *hpaned1;
	GtkWidget *scrolledwindow1;
	GtkWidget *hbuttonbox1;
	GtkWidget *buttonRefresh;
	GtkWidget *buttonConfigure;
	GtkWidget *buttonClose;
	GtkWidget *buttonAbout;
	GdkPixbuf *icon;
	GtkCellRenderer *treeRenderer;
	GtkTreeViewColumn *treeColumn;

	windowMain = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_name (windowMain, "windowMain");
	gtk_window_set_title (GTK_WINDOW (windowMain), "USB Viewer");
	gtk_window_set_default_size (GTK_WINDOW (windowMain), 600, 300);

	icon = gdk_pixbuf_new_from_xpm_data((const char **)usbview_icon);
	gtk_window_set_icon(GTK_WINDOW(windowMain), icon);

	vbox1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_widget_set_name (vbox1, "vbox1");
	gtk_widget_show (vbox1);
	gtk_container_add (GTK_CONTAINER (windowMain), vbox1);

	hpaned1 = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_set_name (hpaned1, "hpaned1");
	gtk_widget_show (hpaned1);
	gtk_box_pack_start (GTK_BOX (vbox1), hpaned1, TRUE, TRUE, 0);

	treeStore = gtk_tree_store_new (N_COLUMNS,
				G_TYPE_STRING,	/* NAME_COLUMN */
				G_TYPE_INT,	/* DEVICE_ADDR_COLUMN */
				G_TYPE_STRING	/* COLOR_COLUMN */);
	treeUSB = gtk_tree_view_new_with_model (GTK_TREE_MODEL (treeStore));
	treeRenderer = gtk_cell_renderer_text_new ();
	treeColumn = gtk_tree_view_column_new_with_attributes (
					"USB devices",
					treeRenderer,
					"text", NAME_COLUMN,
					"foreground", COLOR_COLUMN,
					NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (treeUSB), treeColumn);
	gtk_widget_set_name (treeUSB, "treeUSB");
	gtk_widget_show (treeUSB);
	gtk_paned_pack1 (GTK_PANED (hpaned1), treeUSB, FALSE, FALSE);

	scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
	gtk_widget_set_name (scrolledwindow1, "scrolledwindow1");
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
	gtk_widget_show (scrolledwindow1);
	gtk_paned_pack2 (GTK_PANED (hpaned1), scrolledwindow1, TRUE, FALSE);

	textDescriptionBuffer = gtk_text_buffer_new(NULL);
	//textDescription = gtk_text_new (NULL, NULL);
	textDescriptionView = gtk_text_view_new_with_buffer(textDescriptionBuffer);
	gtk_widget_set_name (textDescriptionView, "textDescription");
	gtk_text_view_set_editable(GTK_TEXT_VIEW(textDescriptionView), FALSE);
	gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textDescriptionView), FALSE);
	gtk_widget_show (textDescriptionView);
	gtk_container_add (GTK_CONTAINER (scrolledwindow1), textDescriptionView);

	hbuttonbox1 = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_set_name (hbuttonbox1, "hbuttonbox1");
	gtk_widget_show (hbuttonbox1);
	gtk_box_pack_start (GTK_BOX (vbox1), hbuttonbox1, FALSE, FALSE, 5);
	//gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox1), 10);
	//gtk_button_box_set_child_size (GTK_BUTTON_BOX (hbuttonbox1), 50, 25);
	//gtk_button_box_set_child_ipadding (GTK_BUTTON_BOX (hbuttonbox1), 25, 10);

	buttonRefresh = gtk_button_new_with_label("Refresh");
	gtk_widget_set_name (buttonRefresh, "buttonRefresh");
	gtk_widget_show (buttonRefresh);
	gtk_container_add (GTK_CONTAINER (hbuttonbox1), buttonRefresh);
	gtk_container_set_border_width (GTK_CONTAINER (buttonRefresh), 4);
	gtk_widget_set_can_default (buttonRefresh, TRUE);

	buttonConfigure = gtk_button_new_with_label ("Configure...");
	gtk_widget_set_name (buttonConfigure, "buttonConfigure");
	gtk_widget_show (buttonConfigure);
	gtk_container_add (GTK_CONTAINER (hbuttonbox1), buttonConfigure);
	gtk_container_set_border_width (GTK_CONTAINER (buttonConfigure), 4);
	gtk_widget_set_can_default (buttonConfigure, TRUE);

	buttonAbout = gtk_button_new_with_label("About");
	gtk_widget_set_name (buttonAbout, "buttonAbout");
	gtk_widget_show (buttonAbout);
	gtk_container_add (GTK_CONTAINER (hbuttonbox1), buttonAbout);
	gtk_container_set_border_width (GTK_CONTAINER (buttonAbout), 4);
	gtk_widget_set_can_default (buttonAbout, TRUE);

	buttonClose = gtk_button_new_with_label("Quit");
	gtk_widget_set_name (buttonClose, "buttonClose");
	gtk_widget_show (buttonClose);
	gtk_container_add (GTK_CONTAINER (hbuttonbox1), buttonClose);
	gtk_container_set_border_width (GTK_CONTAINER (buttonClose), 4);
	gtk_widget_set_can_default (buttonClose, TRUE);

	g_signal_connect (G_OBJECT (windowMain), "delete_event",
			    G_CALLBACK (on_window1_delete_event),
			    NULL);
	g_signal_connect (G_OBJECT (buttonRefresh), "clicked",
			    G_CALLBACK (on_buttonRefresh_clicked),
			    NULL);
	g_signal_connect (G_OBJECT (buttonConfigure), "clicked",
			    G_CALLBACK (on_buttonConfigure_clicked),
			    NULL);
	g_signal_connect (G_OBJECT (buttonAbout), "clicked",
			    G_CALLBACK (on_buttonAbout_clicked),
			    NULL);
	g_signal_connect (G_OBJECT (buttonClose), "clicked",
			    G_CALLBACK (on_buttonClose_clicked),
			    NULL);

	/* create our timer */
	//timer = gtk_timeout_add (2000, on_timer_timeout, 0);
	
	return windowMain;
}
Beispiel #11
0
Datei: gtk.c Projekt: Airr/Claro
void cgraphics_widget_create( widget_t *widget )
{
	widget_t *parent;
	
	parent = (widget_t *)object_parent(widget);
	
	/* check for parent */
	if ( parent == NULL )
	{
		clog( CL_ERROR, "Widget requires parent, none given." );
		return;
	}
	
	/* FIXME: height should be determined from font height in pixels */
	if ( widget->size_req->h == -1 )
		widget->size_req->h = 25;
	
	gtk_widget_set_size_request( GTK_WIDGET(widget->native), widget->size_req->w, widget->size_req->h );
	
	g_signal_connect( G_OBJECT(widget->native), "configure_event", G_CALLBACK(cgraphics_resized_handler), widget );
	g_signal_connect_swapped( G_OBJECT(widget->native), "destroy", G_CALLBACK(cgraphics_destroy_handler), widget );
	
	if ( widget->flags & cWidgetCustomDraw )
	{
		g_signal_connect( G_OBJECT(widget->native), "screen-changed", G_CALLBACK(cgraphics_screen_changed_handler), widget );
		g_signal_connect( G_OBJECT(widget->native), "expose-event", G_CALLBACK(cgraphics_cd_expose_handler), widget );
	}
	
	if ( widget->container != 0 )
		g_signal_connect( G_OBJECT(widget->container), "size_allocate", G_CALLBACK(cgraphics_resized2_handler), widget );
	else
		g_signal_connect( G_OBJECT(widget->native), "size_allocate", G_CALLBACK(cgraphics_resized2_handler), widget );
	
	if ( !strcmp( parent->object.type, "claro.graphics.widgets.splitter" ) )
	{
		size_t splitter_num = (size_t)parent->ndata;
		splitter_widget_t *sw = (splitter_widget_t *)parent;
			
		if ( splitter_num == 0 )
			gtk_paned_pack1( GTK_PANED(parent->native), widget->native, true, false );
		else
			gtk_paned_pack2( GTK_PANED(parent->native), widget->native, true, false );
		
		sw->children[splitter_num].w = widget;
		
		parent->ndata = (void *)(splitter_num+1);
	}
	else if ( !strcmp( parent->object.type, "claro.graphics.widgets.workspace" ) )
	{
		gtk_notebook_append_page( widget_get_container(OBJECT(parent)), widget->native, NULL );
	}
	else
	{
		gtk_layout_put( GTK_LAYOUT(widget_get_container(OBJECT(parent))), widget->native, widget->size_req->x, widget->size_req->y );
	}
	
	g_object_set_data( widget->native, "claro_widget", widget );
	
	if ( widget->flags & cWidgetCustomDraw )
		cgraphics_screen_changed_handler( widget->native, NULL, widget );
	
	gtk_widget_show( GTK_WIDGET(widget->native) );
}
Beispiel #12
0
static void
book_shell_content_constructed (GObject *object)
{
	EBookShellContentPrivate *priv;
	EShellView *shell_view;
	EShellWindow *shell_window;
	EShellContent *shell_content;
	EShellTaskbar *shell_taskbar;
	GtkWidget *container;
	GtkWidget *widget;

	priv = E_BOOK_SHELL_CONTENT_GET_PRIVATE (object);

	/* Chain up to parent's constructed() method. */
	G_OBJECT_CLASS (e_book_shell_content_parent_class)->constructed (object);

	shell_content = E_SHELL_CONTENT (object);
	shell_view = e_shell_content_get_shell_view (shell_content);
	shell_window = e_shell_view_get_shell_window (shell_view);
	shell_taskbar = e_shell_view_get_shell_taskbar (shell_view);

	container = GTK_WIDGET (object);

	widget = e_paned_new (GTK_ORIENTATION_VERTICAL);
	gtk_container_add (GTK_CONTAINER (container), widget);
	priv->paned = g_object_ref (widget);
	gtk_widget_show (widget);

	g_object_bind_property (
		object, "orientation",
		widget, "orientation",
		G_BINDING_SYNC_CREATE);

	container = widget;

	widget = gtk_notebook_new ();
	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
	gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
	gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE);
	priv->notebook = g_object_ref (widget);
	gtk_widget_show (widget);

	widget = eab_contact_display_new ();
	eab_contact_display_set_mode (
		EAB_CONTACT_DISPLAY (widget),
		EAB_CONTACT_DISPLAY_RENDER_NORMAL);

	eab_contact_display_set_show_maps (
		EAB_CONTACT_DISPLAY (widget),
		priv->preview_show_maps);

	g_object_bind_property (
		object, "preview-show-maps",
		widget, "show-maps",
		G_BINDING_SYNC_CREATE);

	gtk_widget_show (widget);

	g_signal_connect_swapped (
		widget, "send-message",
		G_CALLBACK (book_shell_content_send_message_cb), object);

	g_signal_connect_swapped (
		widget, "status-message",
		G_CALLBACK (e_shell_taskbar_set_message),
		shell_taskbar);

	widget = e_preview_pane_new (E_WEB_VIEW (widget));
	gtk_paned_pack2 (GTK_PANED (container), widget, FALSE, FALSE);
	priv->preview_pane = g_object_ref (widget);
	gtk_widget_show (widget);

	g_object_bind_property (
		object, "preview-visible",
		widget, "visible",
		G_BINDING_SYNC_CREATE);

	/* Restore pane positions from the last session once
	 * the shell view is fully initialized and visible. */
	g_signal_connect (
		shell_window, "shell-view-created::addressbook",
		G_CALLBACK (book_shell_content_restore_state_cb),
		shell_content);
}
Beispiel #13
0
int
main(int argc, char **argv)
{
	GtkWidget *label, *terminal, *tophalf, *pane, *window, *sw;
	AtkObject *obj;
	char *text, *p;
	gunichar c;
	guint count;

	gtk_init(&argc, &argv);

	contents = g_array_new(TRUE, FALSE, sizeof(gunichar));

	terminal_init(&terminal);

#ifdef USE_TEXT_VIEW
	tophalf = gtk_scrolled_window_new(NULL, terminal_adjustment(terminal));
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tophalf),
				       GTK_POLICY_AUTOMATIC,
				       GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(tophalf), terminal);
#else
	tophalf = gtk_hbox_new(FALSE, 0);

	gtk_box_pack_start(GTK_BOX(tophalf), terminal, TRUE, TRUE, 0);
	gtk_widget_show(terminal);

	GtkWidget* scrollbar = gtk_vscrollbar_new(terminal_adjustment(terminal));
	gtk_box_pack_start(GTK_BOX(tophalf), scrollbar, FALSE, TRUE, 0);
	gtk_widget_show(scrollbar);
#endif
	gtk_widget_show(terminal);

	label = gtk_label_new("");
	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);

	sw = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), label);
	gtk_widget_show(label);

	pane = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
	gtk_paned_pack1(GTK_PANED(pane), tophalf, TRUE, FALSE);
	gtk_paned_pack2(GTK_PANED(pane), sw, TRUE, FALSE);
	gtk_widget_show(tophalf);
	gtk_widget_show(sw);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	g_signal_connect(G_OBJECT(window), "delete_event",
			 G_CALLBACK(gtk_main_quit), NULL);
	gtk_container_add(GTK_CONTAINER(window), pane);
	gtk_widget_show(pane);

	obj = gtk_widget_get_accessible(terminal);
	g_assert(obj != NULL);
	g_signal_connect(G_OBJECT(obj), "text-changed::insert",
			 G_CALLBACK(text_changed_insert), label);
	g_signal_connect(G_OBJECT(obj), "text-changed::delete",
			 G_CALLBACK(text_changed_delete), label);
	g_signal_connect(G_OBJECT(obj), "text-caret-moved",
			 G_CALLBACK(text_caret_moved), label);
	g_signal_connect(G_OBJECT(obj), "text-selection-changed",
			 G_CALLBACK(text_selection_changed), label);

	count = (guint)atk_text_get_character_count(ATK_TEXT(obj));
	if (count > 0) {
		text = atk_text_get_text(ATK_TEXT(obj), 0, count);
		if (text != NULL) {
			for (p = text;
			     contents->len < count;
			     p = g_utf8_next_char(p)) {
				c = g_utf8_get_char(p);
				g_array_append_val(contents, c);
			}
			g_free(text);
		}
	}
	terminal_shell(terminal);

	gtk_window_set_default_size(GTK_WINDOW(window), 600, 450);
	gtk_widget_show(window);

	update_contents(obj, terminal);

	gtk_main();

	g_array_free(contents, TRUE);
	contents = NULL;

	return 0;
}
static void
gpinstruct_analyzer_examinee_view_init (GPInstructAnalyzerExamineeView *object)
{
	object->priv = GPINSTRUCT_ANALYZER_EXAMINEE_VIEW_GET_PRIVATE (object);
	GPInstructAnalyzerExamineeViewPrivate *priv = object->priv;

	GtkTreeSelection *selection;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;

	gtk_paned_set_position (GTK_PANED (object), 200);

	GtkWidget *examinee_scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (examinee_scrolledwindow),
	                                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_paned_pack1 (GTK_PANED (object), examinee_scrolledwindow, FALSE, TRUE);
	priv->examinee_scrolledwindow = examinee_scrolledwindow;

	priv->examinee_store = gtk_list_store_new (EXAMINEE_N_COLUMNS,
	                                                   G_TYPE_STRING,
	                                                   G_TYPE_POINTER);

	GtkWidget *examinee_treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->examinee_store));
	gtk_container_add (GTK_CONTAINER (examinee_scrolledwindow), examinee_treeview);
	priv->examinee_treeview = examinee_treeview;

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (examinee_treeview));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
	g_signal_connect (selection, "changed",
	                  G_CALLBACK (examinee_tree_selection_changed_cb),
	                  object);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Examinees"),
	                                                   renderer,
	                                                   "text", EXAMINEE_NAME_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_expand (column, TRUE);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (examinee_treeview), column);

	GtkWidget *vpaned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
	gtk_paned_pack2 (GTK_PANED (object), vpaned, TRUE, TRUE);

	GtkWidget *project_scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (project_scrolledwindow),
	                                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_paned_pack1 (GTK_PANED (vpaned), project_scrolledwindow, TRUE, TRUE);
	priv->project_scrolledwindow = project_scrolledwindow;

	priv->project_store = gtk_tree_store_new (PROJECT_N_COLUMNS,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_UINT,
	                                                  G_TYPE_POINTER);

	GtkWidget *project_treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->project_store));
	gtk_container_add (GTK_CONTAINER (project_scrolledwindow), project_treeview);
	priv->project_treeview = project_treeview;

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (project_treeview));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
	g_signal_connect (selection, "changed",
	                  G_CALLBACK (project_tree_selection_changed_cb),
	                  object);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Project View"),
	                                                   renderer,
	                                                   "text", PROJECT_TITLE_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_expand (column, TRUE);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Total Items"),
	                                                   renderer,
	                                                   "text", PROJECT_ITEMS_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Frequency"),
	                                                   renderer,
	                                                   "text", PROJECT_FREQUENCY_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Total Score"),
	                                                   renderer,
	                                                   "text", PROJECT_SCORE_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Average Score"),
	                                                   renderer,
	                                                   "text", PROJECT_AVE_SCORE_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Percentage"),
	                                                   renderer,
	                                                   "text", PROJECT_PERCENTAGE_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Time Spent"),
	                                                   renderer,
	                                                   "text", PROJECT_TIME_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Average Time Spent"),
	                                                   renderer,
	                                                   "text", PROJECT_AVE_TIME_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	GtkWidget *test_scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (test_scrolledwindow),
	                                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_paned_pack2 (GTK_PANED (vpaned), test_scrolledwindow, TRUE, TRUE);
	priv->test_scrolledwindow = test_scrolledwindow;

	priv->test_store = gtk_tree_store_new (TEST_N_COLUMNS,
	                                               G_TYPE_STRING,
	                                               G_TYPE_STRING,
	                                               G_TYPE_STRING,
	                                               G_TYPE_STRING,
	                                               G_TYPE_STRING,
	                                               G_TYPE_STRING,
	                                               G_TYPE_STRING,
	                                               G_TYPE_STRING,
	                                               G_TYPE_UINT,
	                                               G_TYPE_POINTER);

	GtkWidget *test_treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->test_store));
	gtk_container_add (GTK_CONTAINER (test_scrolledwindow), test_treeview);
	priv->test_treeview = test_treeview;

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Test View"),
	                                                   renderer,
	                                                   "text", TEST_TITLE_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_expand (column, TRUE);
	gtk_tree_view_column_set_resizable (column, TRUE);
	g_object_set (renderer,
	              "ellipsize", PANGO_ELLIPSIZE_END,
	              "ellipsize-set", TRUE,
	              NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (test_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Number of Choices"),
	                                                   renderer,
	                                                   "text", TEST_ITEMS_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (test_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Frequency"),
	                                                   renderer,
	                                                   "text", TEST_FREQUENCY_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (test_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Total Score"),
	                                                   renderer,
	                                                   "text", TEST_SCORE_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (test_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Percentage"),
	                                                   renderer,
	                                                   "text", TEST_PERCENTAGE_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (test_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Time Spent"),
	                                                   renderer,
	                                                   "text", TEST_TIME_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (test_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Average Time Spent"),
	                                                   renderer,
	                                                   "text", TEST_AVE_TIME_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (test_treeview), column);
}
static void
mucharmap_charmap_init (MucharmapCharmap *charmap)
{
  MucharmapCharmapPrivate *priv;
  GtkWidget *scrolled_window, *view, *chartable, *textview;
  GtkTreeSelection *selection;
  GtkTextBuffer *buffer;
  int page;

  priv = charmap->priv = G_TYPE_INSTANCE_GET_PRIVATE (charmap, MUCHARMAP_TYPE_CHARMAP, MucharmapCharmapPrivate);

  /* FIXME: move this to realize */
  priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
  priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
  priv->hovering_over_link = FALSE;

  /* Left pane */
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
	                              GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
	                                   GTK_SHADOW_ETCHED_IN);

#if GTK_CHECK_VERSION (3, 15, 9)
  gtk_scrolled_window_set_overlay_scrolling (GTK_SCROLLED_WINDOW (scrolled_window), FALSE);
#endif

  view = mucharmap_chapters_view_new ();
  priv->chapters_view = MUCHARMAP_CHAPTERS_VIEW (view);
  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
  g_signal_connect (selection, "changed",
	                G_CALLBACK (chapters_view_selection_changed_cb), charmap);

  gtk_container_add (GTK_CONTAINER (scrolled_window), view);
  gtk_widget_show (view);
  gtk_paned_pack1 (GTK_PANED (charmap), scrolled_window, FALSE, TRUE);
  gtk_widget_show (scrolled_window);

  /* Right pane */
  priv->notebook = gtk_notebook_new ();

  /* Chartable page */
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
	                              GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
	                                   GTK_SHADOW_NONE);

  chartable = mucharmap_chartable_new ();
  priv->chartable = MUCHARMAP_CHARTABLE (chartable);

  g_signal_connect_swapped (chartable, "status-message",
	                        G_CALLBACK (chartable_status_message), charmap);
  g_signal_connect (chartable, "notify::active-character",
	                G_CALLBACK (chartable_sync_active_char), charmap);
  g_signal_connect (chartable, "notify::font-desc",
	                G_CALLBACK (chartable_sync_font_desc), charmap);
  g_signal_connect (chartable, "notify::codepoint-list",
	                G_CALLBACK (chartable_notify_cb), charmap);
  g_signal_connect (chartable, "notify::snap-pow2",
	                G_CALLBACK (chartable_notify_cb), charmap);

  gtk_container_add (GTK_CONTAINER (scrolled_window), chartable);
  gtk_widget_show (chartable);

  page = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
	                               scrolled_window,
	                               gtk_label_new_with_mnemonic (_("Characte_r Table")));
  g_assert (page == MUCHARMAP_CHARMAP_PAGE_CHARTABLE);
  gtk_widget_show (scrolled_window);

  /* Details page */
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
	                              GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
	                                   GTK_SHADOW_ETCHED_IN);

  textview = gtk_text_view_new ();
  priv->details_view = GTK_TEXT_VIEW (textview);
  gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), FALSE);
  gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview), FALSE);
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview),
	                           GTK_WRAP_WORD);

  g_signal_connect (textview, "style-set",
	                G_CALLBACK (details_style_set), charmap);
  g_signal_connect (textview, "key-press-event",
	                G_CALLBACK (details_key_press_event), charmap);
  g_signal_connect (textview, "event-after",
	                G_CALLBACK (details_event_after), charmap);
  g_signal_connect (textview, "motion-notify-event",
	                G_CALLBACK (details_motion_notify_event), charmap);
  g_signal_connect (textview, "visibility-notify-event",
	                G_CALLBACK (details_visibility_notify_event), charmap);

  buffer = gtk_text_view_get_buffer (priv->details_view);
  priv->text_tag_gimongous =
	gtk_text_buffer_create_tag (buffer, "gimongous",
	                            NULL);
  priv->text_tag_big =
	gtk_text_buffer_create_tag (buffer, "big",
	                            NULL);
  gtk_text_buffer_create_tag (buffer, "bold",
	                          "weight", PANGO_WEIGHT_BOLD,
	                          NULL);
  gtk_text_buffer_create_tag (buffer, "detail-value",
	                          NULL);

  gtk_container_add (GTK_CONTAINER (scrolled_window), textview);
  gtk_widget_show (textview);

  page = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
	                               scrolled_window,
	                               gtk_label_new_with_mnemonic (_("Character _Details")));
  g_assert (page == MUCHARMAP_CHARMAP_PAGE_DETAILS);
  gtk_widget_show (scrolled_window);

  priv->active_page = 0;
  gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 0);
  g_signal_connect (priv->notebook, "switch-page",
	                G_CALLBACK (notebook_switch_page), charmap);

  gtk_paned_pack2 (GTK_PANED (charmap), priv->notebook, TRUE, TRUE);
  gtk_widget_show (priv->notebook);
}
Beispiel #16
0
void
browser_dialog_open (const gchar *plug_in_binary)
{
  GtkWidget   *window;
  GtkWidget   *main_vbox;
  GtkWidget   *vbox;
  GtkWidget   *toolbar;
  GtkWidget   *paned;
  GtkWidget   *scrolled;
  GtkToolItem *item;
  GtkAction   *action;
  DialogData   data = { 720, 560, 240, TRUE, 1.0 };

  gimp_ui_init (plug_in_binary, TRUE);

  gimp_get_data (GIMP_HELP_BROWSER_DIALOG_DATA, &data);

  /*  the dialog window  */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), _("GIMP Help Browser"));
  gtk_window_set_role (GTK_WINDOW (window), plug_in_binary);

  gtk_window_set_default_size (GTK_WINDOW (window), data.width, data.height);

  g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_main_quit),
                    NULL);

  window_set_icons (window);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (vbox);

  ui_manager = ui_manager_new (window);

  toolbar = gtk_ui_manager_get_widget (ui_manager, "/help-browser-toolbar");
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
  gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
  gtk_widget_show (toolbar);

  item = g_object_new (GTK_TYPE_MENU_TOOL_BUTTON, NULL);
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0);
  gtk_widget_show (GTK_WIDGET (item));

  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/forward");
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (item), action);
  g_object_notify (G_OBJECT (action), "tooltip");
  button_next = GTK_WIDGET (item);

  item = g_object_new (GTK_TYPE_MENU_TOOL_BUTTON, NULL);
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, 0);
  gtk_widget_show (GTK_WIDGET (item));

  action = gtk_ui_manager_get_action (ui_manager,
                                      "/ui/help-browser-popup/back");
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (item), action);
  g_object_notify (G_OBJECT (action), "tooltip");
  button_prev = GTK_WIDGET (item);

  item =
    GTK_TOOL_ITEM (gtk_ui_manager_get_widget (ui_manager,
                                              "/help-browser-toolbar/space"));
  gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (item), FALSE);
  gtk_tool_item_set_expand (item, TRUE);

  /*  the horizontal paned  */
  paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_box_pack_start (GTK_BOX (vbox), paned, TRUE, TRUE, 0);
  gtk_widget_show (paned);

  scrolled = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_paned_add1 (GTK_PANED (paned), scrolled);
  gtk_paned_set_position (GTK_PANED (paned), data.paned_position);

  sidebar = scrolled;

  if (data.show_index)
    gtk_widget_show (sidebar);

  tree_view = gtk_tree_view_new ();
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
  gtk_container_add (GTK_CONTAINER (scrolled), tree_view);
  gtk_widget_show (tree_view);

  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), -1,
                                               NULL,
                                               gtk_cell_renderer_text_new (),
                                               "text", 1,
                                               NULL);

  g_signal_connect (tree_view, "row-activated",
                    G_CALLBACK (row_activated),
                    NULL);

  /*  HTML view  */
  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_widget_show (main_vbox);
  gtk_paned_pack2 (GTK_PANED (paned), main_vbox, TRUE, TRUE);

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

  gtk_widget_set_size_request (scrolled, 300, 200);
  gtk_box_pack_start (GTK_BOX (main_vbox), scrolled, TRUE, TRUE, 0);
  gtk_widget_show (scrolled);

  view = webkit_web_view_new ();
  webkit_web_view_set_maintains_back_forward_list (WEBKIT_WEB_VIEW (view),
                                                   TRUE);
  gtk_container_add (GTK_CONTAINER (scrolled), view);
  gtk_widget_show (view);

  g_signal_connect (view, "realize",
                    G_CALLBACK (view_realize),
                    NULL);
  g_signal_connect (view, "unrealize",
                    G_CALLBACK (view_unrealize),
                    NULL);

  g_signal_connect (view, "popup-menu",
                    G_CALLBACK (view_popup_menu),
                    NULL);
  g_signal_connect (view, "button-press-event",
                    G_CALLBACK (view_button_press),
                    NULL);
  g_signal_connect (view, "key-press-event",
                    G_CALLBACK (view_key_press),
                    NULL);

  webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW (view), data.zoom);

  g_signal_connect (view, "title-changed",
                    G_CALLBACK (title_changed),
                    window);

  g_signal_connect (view, "load-started",
                    G_CALLBACK (load_started),
                    NULL);
  g_signal_connect (view, "load-finished",
                    G_CALLBACK (load_finished),
                    NULL);

  gtk_widget_grab_focus (view);

  g_signal_connect (window, "unmap",
                    G_CALLBACK (dialog_unmap),
                    paned);

  update_actions ();

  /* Searchbar */
  searchbar = build_searchbar ();
  gtk_box_pack_start (GTK_BOX (main_vbox), searchbar, FALSE, FALSE, 0);
}
Beispiel #17
0
void 
gui_create_tasks(GUI *appGUI) {

GtkWidget           *vbox1;
GtkWidget           *vbox2;
GtkWidget           *table;
GtkWidget           *label;
GtkWidget           *top_scrolledwindow;
GtkWidget           *hseparator;
GtkWidget           *close_button;
GtkCellRenderer     *renderer;
GtkWidget           *top_viewport;
GtkWidget           *bottom_viewport;
GtkTextBuffer       *text_buffer;
GError              *error = NULL;
GtkActionGroup      *action_group = NULL;
gchar tmpbuf[BUFFER_SIZE];

 const gchar *ui_info =
"  <toolbar name=\"toolbar\">\n"
"    <toolitem name=\"add\" action=\"add\" />\n"
"    <toolitem name=\"delete\" action=\"delete\" />\n"
"    <separator name=\"sep1\" />\n"
"    <toolitem name=\"edit\" action=\"edit\" />\n"
"  </toolbar>\n";

GtkActionEntry entries[] = {
  { "add", OSMO_STOCK_TASKS_ADD, _("New task"), NULL, _("New task"), NULL },
  { "edit", OSMO_STOCK_TASKS_EDIT, _("Edit task"), NULL, _("Edit task"), NULL },
  { "delete", OSMO_STOCK_TASKS_REMOVE, _("Remove task"), NULL, _("Remove task"), NULL },
};

guint n_entries = G_N_ELEMENTS (entries);

    appGUI->tsk->filter_index = 0;

    vbox1 = gtk_vbox_new (FALSE, 1);
    gtk_widget_show (vbox1);
    gtk_container_set_border_width (GTK_CONTAINER (vbox1), 8);
    sprintf(tmpbuf, "<b>%s</b>", _("Tasks"));
    gui_add_to_notebook (vbox1, tmpbuf, appGUI);

    appGUI->tsk->vbox = GTK_BOX(vbox1);

    /*-------------------------------------------------------------------------------------*/

    action_group = gtk_action_group_new ("_actions");
    gtk_action_group_add_actions (action_group, entries, n_entries, NULL);
    gtk_action_group_set_sensitive(action_group, TRUE);

    appGUI->tsk->tasks_uim_widget = gtk_ui_manager_new ();

    gtk_ui_manager_insert_action_group (appGUI->tsk->tasks_uim_widget, action_group, 0);
    g_signal_connect (appGUI->tsk->tasks_uim_widget, "add_widget", G_CALLBACK (add_tasks_toolbar_widget), appGUI);

    if (!gtk_ui_manager_add_ui_from_string (appGUI->tsk->tasks_uim_widget, ui_info, -1, &error)) {
        g_message ("building toolbar failed: %s", error->message);
        g_error_free (error);
    }
    gtk_ui_manager_ensure_update (appGUI->tsk->tasks_uim_widget);

    gtk_toolbar_set_style (appGUI->tsk->tasks_toolbar, GTK_TOOLBAR_ICONS);
    gtk_toolbar_set_tooltips (appGUI->tsk->tasks_toolbar, config.enable_tooltips);

    /*-------------------------------------------------------------------------------------*/
    /* assign callbacks */

    g_signal_connect (G_OBJECT(gtk_ui_manager_get_widget (appGUI->tsk->tasks_uim_widget, "/toolbar/add")), "clicked", 
                      G_CALLBACK(tasks_add_item_cb), appGUI);
    g_signal_connect (G_OBJECT(gtk_ui_manager_get_widget (appGUI->tsk->tasks_uim_widget, "/toolbar/edit")), "clicked", 
                      G_CALLBACK(tasks_edit_item_cb), appGUI);
    g_signal_connect (G_OBJECT(gtk_ui_manager_get_widget (appGUI->tsk->tasks_uim_widget, "/toolbar/delete")), "clicked", 
                      G_CALLBACK(tasks_remove_item_cb), appGUI);

    /*-------------------------------------------------------------------------------------*/

    gtk_widget_set_sensitive(gtk_ui_manager_get_widget (appGUI->tsk->tasks_uim_widget, "/toolbar/edit"), FALSE);
    gtk_widget_set_sensitive(gtk_ui_manager_get_widget (appGUI->tsk->tasks_uim_widget, "/toolbar/delete"), FALSE);

    hseparator = gtk_hseparator_new ();
    gtk_widget_show (hseparator);
    gtk_box_pack_start (GTK_BOX (vbox1), hseparator, FALSE, TRUE, 6);

    table = gtk_table_new (1, 4, FALSE);
    gtk_widget_show (table);
    gtk_box_pack_start (GTK_BOX (vbox1), table, FALSE, TRUE, 0);
    gtk_table_set_col_spacings (GTK_TABLE (table), 8);

    sprintf(tmpbuf, "<b>%s:</b>", _("Category filter"));
    label = gtk_label_new (tmpbuf);
    gtk_widget_show (label);
    gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);

    appGUI->tsk->cf_combobox = gtk_combo_box_new_text ();
    gtk_widget_show (appGUI->tsk->cf_combobox);
    gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (appGUI->tsk->cf_combobox), FALSE);
    GTK_WIDGET_UNSET_FLAGS(appGUI->tsk->cf_combobox, GTK_CAN_FOCUS);
    gtk_table_attach (GTK_TABLE (table), appGUI->tsk->cf_combobox, 1, 2, 0, 1,
                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                     (GtkAttachOptions) (GTK_FILL), 0, 0);
    g_signal_connect(appGUI->tsk->cf_combobox, "changed", 
                     G_CALLBACK(category_filter_cb), appGUI);
    g_signal_connect(G_OBJECT(appGUI->tsk->cf_combobox), "focus", 
                     G_CALLBACK(category_combo_box_focus_cb), NULL);

    appGUI->tsk->n_items_label = gtk_label_new ("");
    gtk_widget_show (appGUI->tsk->n_items_label);
    gtk_widget_set_size_request (appGUI->tsk->n_items_label, 100, -1);
    gtk_table_attach (GTK_TABLE (table), appGUI->tsk->n_items_label, 3, 4, 0, 1,
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
    gtk_label_set_use_markup (GTK_LABEL (appGUI->tsk->n_items_label), TRUE);

    hseparator = gtk_hseparator_new ();
    gtk_widget_show (hseparator);
    gtk_box_pack_start (GTK_BOX (vbox1), hseparator, FALSE, TRUE, 6);

    /*-------------------------------------------------------------------------------------*/

    appGUI->tsk->tasks_paned = gtk_vpaned_new();
    gtk_widget_show (appGUI->tsk->tasks_paned);
    gtk_paned_set_position(GTK_PANED(appGUI->tsk->tasks_paned), 99999);
    gtk_box_pack_start(GTK_BOX(vbox1), appGUI->tsk->tasks_paned, TRUE, TRUE, 0);

    top_viewport = gtk_viewport_new (NULL, NULL);
    gtk_widget_show (top_viewport);
    gtk_viewport_set_shadow_type (GTK_VIEWPORT (top_viewport), GTK_SHADOW_NONE);
    gtk_paned_pack1 (GTK_PANED (appGUI->tsk->tasks_paned), top_viewport, FALSE, TRUE);

    top_scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
    gtk_widget_show (top_scrolledwindow);
    gtk_container_add (GTK_CONTAINER (top_viewport), top_scrolledwindow);

    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (top_scrolledwindow), GTK_SHADOW_IN);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (top_scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

    appGUI->tsk->tasks_list_store = gtk_list_store_new(TASKS_NUM_COLUMNS, 
                                         G_TYPE_BOOLEAN,
                                         G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING,
                                         G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);

    appGUI->tsk->tasks_filter = gtk_tree_model_filter_new(GTK_TREE_MODEL(appGUI->tsk->tasks_list_store), NULL);
    gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER(appGUI->tsk->tasks_filter), 
                                            (GtkTreeModelFilterVisibleFunc)tasks_list_filter_cb, 
                                            appGUI, NULL);

    appGUI->tsk->tasks_sort = gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(appGUI->tsk->tasks_filter));

    appGUI->tsk->tasks_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(appGUI->tsk->tasks_sort));
    gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(appGUI->tsk->tasks_list), config.tasks_rules_hint);
    gtk_widget_show (appGUI->tsk->tasks_list);
    GTK_WIDGET_SET_FLAGS (appGUI->tsk->tasks_list, GTK_CAN_DEFAULT);
    gtk_widget_modify_fg(GTK_WIDGET(appGUI->tsk->tasks_list), GTK_STATE_SELECTED,
                         (& GTK_WIDGET(appGUI->tsk->tasks_list)->style->base[GTK_STATE_SELECTED]));
    gtk_widget_modify_fg(GTK_WIDGET(appGUI->tsk->tasks_list), GTK_STATE_NORMAL,
                         (& GTK_WIDGET(appGUI->tsk->tasks_list)->style->bg[GTK_STATE_NORMAL]));

    g_signal_connect(G_OBJECT(appGUI->tsk->tasks_list), "button_press_event",
                     G_CALLBACK(list_dbclick_cb), appGUI);

    appGUI->tsk->tasks_list_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (appGUI->tsk->tasks_list));
    g_signal_connect(G_OBJECT(appGUI->tsk->tasks_list_selection), "changed",
                     G_CALLBACK(tasks_item_selected), appGUI);

    /* create columns */

    renderer = gtk_cell_renderer_toggle_new();
    appGUI->tsk->tasks_columns[COLUMN_DONE] = gtk_tree_view_column_new_with_attributes (_("Done"),
                             renderer,
                             "active", COLUMN_DONE,
                             NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW(appGUI->tsk->tasks_list), appGUI->tsk->tasks_columns[COLUMN_DONE]);

    g_signal_connect (renderer, "toggled", G_CALLBACK (done_toggled), appGUI);

    renderer = gtk_cell_renderer_text_new();
    appGUI->tsk->tasks_columns[COLUMN_DUE_DATE] = gtk_tree_view_column_new_with_attributes(_("Due date"),
                              renderer,
                              "text", COLUMN_DUE_DATE,
                              "strikethrough", COLUMN_DONE,
                              "foreground", COLUMN_COLOR,
                              NULL);
    gtk_tree_view_column_set_visible (appGUI->tsk->tasks_columns[COLUMN_DUE_DATE], config.visible_due_date_column);
    gtk_tree_view_append_column(GTK_TREE_VIEW(appGUI->tsk->tasks_list), appGUI->tsk->tasks_columns[COLUMN_DUE_DATE]);

    renderer = gtk_cell_renderer_text_new();
    appGUI->tsk->tasks_columns[COLUMN_DUE_DATE_JULIAN] = gtk_tree_view_column_new_with_attributes(NULL,
                              renderer,
                              "text", COLUMN_DUE_DATE_JULIAN,
                              "strikethrough", COLUMN_DONE,
                              "foreground", COLUMN_COLOR,
                              NULL);
    gtk_tree_view_column_set_visible (appGUI->tsk->tasks_columns[COLUMN_DUE_DATE_JULIAN], FALSE);
    gtk_tree_view_append_column(GTK_TREE_VIEW(appGUI->tsk->tasks_list), appGUI->tsk->tasks_columns[COLUMN_DUE_DATE_JULIAN]);

    renderer = gtk_cell_renderer_text_new();
    appGUI->tsk->tasks_columns[COLUMN_START_DATE_JULIAN] = gtk_tree_view_column_new_with_attributes(NULL,
                              renderer,
                              "text", COLUMN_START_DATE_JULIAN,
                              "strikethrough", COLUMN_DONE,
                              "foreground", COLUMN_COLOR,
                              NULL);
    gtk_tree_view_column_set_visible (appGUI->tsk->tasks_columns[COLUMN_START_DATE_JULIAN], FALSE);
    gtk_tree_view_append_column(GTK_TREE_VIEW(appGUI->tsk->tasks_list), appGUI->tsk->tasks_columns[COLUMN_START_DATE_JULIAN]);

    renderer = gtk_cell_renderer_text_new();
    appGUI->tsk->tasks_columns[COLUMN_PRIORITY] = gtk_tree_view_column_new_with_attributes(_("Priority"),
                              renderer,
                              "text", COLUMN_PRIORITY,
                              "strikethrough", COLUMN_DONE,
                              "foreground", COLUMN_COLOR,
                              NULL);
    gtk_tree_view_column_set_visible (appGUI->tsk->tasks_columns[COLUMN_PRIORITY], config.visible_priority_column);
    gtk_tree_view_append_column(GTK_TREE_VIEW(appGUI->tsk->tasks_list), appGUI->tsk->tasks_columns[COLUMN_PRIORITY]);

    renderer = gtk_cell_renderer_text_new();
    appGUI->tsk->tasks_columns[COLUMN_CATEGORY] = gtk_tree_view_column_new_with_attributes(_("Category"),
                              renderer,
                              "text", COLUMN_CATEGORY,
                              "strikethrough", COLUMN_DONE,
                              "foreground", COLUMN_COLOR,
                              NULL);
    gtk_tree_view_column_set_visible (appGUI->tsk->tasks_columns[COLUMN_CATEGORY], config.visible_category_column);
    gtk_tree_view_append_column(GTK_TREE_VIEW(appGUI->tsk->tasks_list), appGUI->tsk->tasks_columns[COLUMN_CATEGORY]);

    renderer = gtk_cell_renderer_text_new();
    g_object_set(G_OBJECT(renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
    gtk_cell_renderer_set_fixed_size(renderer, 0, -1);
    appGUI->tsk->tasks_columns[COLUMN_SUMMARY] = gtk_tree_view_column_new_with_attributes(_("Summary"),
                              renderer,
                              "text", COLUMN_SUMMARY,
                              "strikethrough", COLUMN_DONE,
                              "foreground", COLUMN_COLOR,
                              NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(appGUI->tsk->tasks_list), appGUI->tsk->tasks_columns[COLUMN_SUMMARY]);


    renderer = gtk_cell_renderer_text_new();
    appGUI->tsk->tasks_columns[COLUMN_DESCRIPTION] = gtk_tree_view_column_new_with_attributes(_("Description"),
                              renderer,
                              "text", COLUMN_DESCRIPTION,
                              NULL);
    gtk_tree_view_column_set_visible (appGUI->tsk->tasks_columns[COLUMN_DESCRIPTION], FALSE);
    gtk_tree_view_append_column(GTK_TREE_VIEW(appGUI->tsk->tasks_list), appGUI->tsk->tasks_columns[COLUMN_DESCRIPTION]);

    renderer = gtk_cell_renderer_text_new();
    appGUI->tsk->tasks_columns[COLUMN_COLOR] = gtk_tree_view_column_new_with_attributes(NULL,
                              renderer,
                              "text", COLUMN_COLOR,
                              NULL);
    gtk_tree_view_column_set_visible (appGUI->tsk->tasks_columns[COLUMN_COLOR], FALSE);
    gtk_tree_view_append_column(GTK_TREE_VIEW(appGUI->tsk->tasks_list), appGUI->tsk->tasks_columns[COLUMN_COLOR]);

    /* configure list options */

    gtk_container_add (GTK_CONTAINER (top_scrolledwindow), appGUI->tsk->tasks_list);
    gtk_tree_view_set_enable_search (GTK_TREE_VIEW(appGUI->tsk->tasks_list), FALSE);

    /* configure sorting */

    gtk_tree_sortable_set_sort_func((GtkTreeSortable *)appGUI->tsk->tasks_sort, 0, 
                                    (GtkTreeIterCompareFunc)custom_tasks_sort_function, NULL, NULL);

    gtk_tree_sortable_set_sort_column_id((GtkTreeSortable *)appGUI->tsk->tasks_sort, COLUMN_DUE_DATE, config.tasks_sorting_order);
    gtk_tree_sortable_set_sort_column_id((GtkTreeSortable *)appGUI->tsk->tasks_sort, COLUMN_PRIORITY, config.tasks_sorting_order);
    gtk_tree_sortable_set_sort_column_id((GtkTreeSortable *)appGUI->tsk->tasks_sort, COLUMN_DONE, config.tasks_sorting_order);

    /*----------------------------------------------------------------------------*/

    bottom_viewport = gtk_viewport_new (NULL, NULL);
    gtk_widget_show (bottom_viewport);
    gtk_viewport_set_shadow_type (GTK_VIEWPORT (bottom_viewport), GTK_SHADOW_NONE);
    gtk_paned_pack2 (GTK_PANED (appGUI->tsk->tasks_paned), bottom_viewport, TRUE, TRUE);

    vbox2 = gtk_vbox_new (FALSE, 0);
    gtk_widget_show (vbox2);
    gtk_container_set_border_width (GTK_CONTAINER (vbox2), 0);
    gtk_container_add (GTK_CONTAINER (bottom_viewport), vbox2);

    appGUI->tsk->panel_hbox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox2), appGUI->tsk->panel_hbox, FALSE, FALSE, 0);
    gtk_widget_show(appGUI->tsk->panel_hbox);

    sprintf(tmpbuf, "%s:", _("Task details"));
    label = gtk_label_new (tmpbuf);
    gtk_widget_show (label);
    gtk_box_pack_start (GTK_BOX (appGUI->tsk->panel_hbox), label, FALSE, FALSE, 0);

    if (config.default_stock_icons) {
        close_button = gui_stock_button(GTK_STOCK_CLOSE, FALSE);
    } else {
        close_button = gui_stock_button(OSMO_STOCK_BUTTON_CLOSE, FALSE);
    }
    GTK_WIDGET_UNSET_FLAGS(close_button, GTK_CAN_FOCUS);
    gtk_button_set_relief (GTK_BUTTON(close_button), GTK_RELIEF_NONE);
    gtk_tooltips_set_tip (appGUI->osmo_tooltips, close_button, _("Close description panel"), NULL);
    gtk_box_pack_end (GTK_BOX (appGUI->tsk->panel_hbox), close_button, FALSE, FALSE, 0);
    g_signal_connect (G_OBJECT (close_button), "clicked",
                        G_CALLBACK (panel_close_desc_cb), appGUI);

    appGUI->tsk->panel_scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
    gtk_widget_show (appGUI->tsk->panel_scrolledwindow);
    gtk_box_pack_start (GTK_BOX (vbox2), appGUI->tsk->panel_scrolledwindow, TRUE, TRUE, 0);
    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (appGUI->tsk->panel_scrolledwindow), GTK_SHADOW_IN);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (appGUI->tsk->panel_scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

    appGUI->tsk->tasks_desc_textview = gtk_text_view_new ();
    gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (appGUI->tsk->tasks_desc_textview), GTK_WRAP_WORD);
    gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(appGUI->tsk->tasks_desc_textview), 4);
    gtk_text_view_set_left_margin(GTK_TEXT_VIEW(appGUI->tsk->tasks_desc_textview), 4);
    gtk_text_view_set_right_margin(GTK_TEXT_VIEW(appGUI->tsk->tasks_desc_textview), 4);
    gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(appGUI->tsk->tasks_desc_textview), FALSE);
    gtk_text_view_set_editable(GTK_TEXT_VIEW(appGUI->tsk->tasks_desc_textview), FALSE);
    gtk_widget_show (appGUI->tsk->tasks_desc_textview);
    gtk_container_add (GTK_CONTAINER (appGUI->tsk->panel_scrolledwindow), appGUI->tsk->tasks_desc_textview);

    text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(appGUI->tsk->tasks_desc_textview));
    gtk_text_buffer_create_tag (text_buffer, "italic",
                  "style", PANGO_STYLE_ITALIC, NULL);
    appGUI->tsk->font_tag_object = gtk_text_buffer_create_tag (text_buffer, "info_font",
                      "font", (gchar *) config.task_info_font, NULL);

}
Beispiel #18
0
/**
 * query_console_page_new
 *
 * Returns: a new #GtkWidget
 */
GtkWidget *
query_console_page_new (TConnection *tcnc)
{
	QueryConsolePage *tconsole;

	g_return_val_if_fail (T_IS_CONNECTION (tcnc), NULL);

	tconsole = QUERY_CONSOLE_PAGE (g_object_new (QUERY_CONSOLE_PAGE_TYPE, NULL));

	tconsole->priv->tcnc = g_object_ref (tcnc);
	
	/* header */
        GtkWidget *label;
	gchar *str;
	str = g_strdup_printf ("<b>%s</b>", _("Query editor"));
	label = gdaui_bar_new (str);
	g_free (str);
        gtk_box_pack_start (GTK_BOX (tconsole), label, FALSE, FALSE, 0);
        gtk_widget_show (label);
	tconsole->priv->header = GDAUI_BAR (label);

	/* main contents */
	GtkWidget *vpaned;
	vpaned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
	tconsole->priv->vpaned = NULL;
	gtk_box_pack_start (GTK_BOX (tconsole), vpaned, TRUE, TRUE, 6);	

	/* top paned for the editor */
	GtkWidget *wid, *vbox, *hbox, *bbox, *hpaned, *button;

	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_paned_pack1 (GTK_PANED (vpaned), hbox, TRUE, FALSE);

	hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_box_pack_start (GTK_BOX (hbox), hpaned, TRUE, TRUE, 0);

	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_paned_pack1 (GTK_PANED (hpaned), vbox, TRUE, FALSE);

	wid = gtk_label_new ("");
	str = g_strdup_printf ("<b>%s</b>", _("SQL code to execute:"));
	gtk_label_set_markup (GTK_LABEL (wid), str);
	g_free (str);
	gtk_widget_set_halign (wid, GTK_ALIGN_START);
	gtk_widget_set_tooltip_markup (wid, QUERY_EDITOR_TOOLTIP);
	gtk_box_pack_start (GTK_BOX (vbox), wid, FALSE, FALSE, 0);

	wid = query_editor_new ();
	tconsole->priv->editor = QUERY_EDITOR (wid);
	gtk_box_pack_start (GTK_BOX (vbox), wid, TRUE, TRUE, 0);
	g_signal_connect (wid, "changed",
			  G_CALLBACK (editor_changed_cb), tconsole);
	g_signal_connect (wid, "execute-request",
			  G_CALLBACK (editor_execute_request_cb), tconsole);
	
	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	tconsole->priv->params_top = vbox;
	gtk_paned_pack2 (GTK_PANED (hpaned), vbox, FALSE, FALSE);
	
	wid = gtk_label_new ("");
	str = g_strdup_printf ("<b>%s</b>", _("Variables' values:"));
	gtk_label_set_markup (GTK_LABEL (wid), str);
	g_free (str);
	gtk_widget_set_halign (wid, GTK_ALIGN_START);
	gtk_box_pack_start (GTK_BOX (vbox), wid, FALSE, FALSE, 0);
	
	GtkWidget *sw;
	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_NONE);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
					GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	tconsole->priv->params_form_box = gtk_viewport_new (NULL, NULL);
	gtk_widget_set_name (tconsole->priv->params_form_box, "gdaui-transparent-background");
	gtk_viewport_set_shadow_type (GTK_VIEWPORT (tconsole->priv->params_form_box), GTK_SHADOW_NONE);
	gtk_container_add (GTK_CONTAINER (sw), tconsole->priv->params_form_box);
	gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
	gtk_widget_set_size_request (tconsole->priv->params_form_box, 250, -1);

	wid = gtk_label_new ("");
	gtk_label_set_markup (GTK_LABEL (wid), VARIABLES_HELP);
	gtk_widget_set_halign (wid, GTK_ALIGN_START);
	gtk_container_add (GTK_CONTAINER (tconsole->priv->params_form_box), wid);
	tconsole->priv->params_form = wid;
	
	bbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
	gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END);
	gtk_box_pack_start (GTK_BOX (hbox), bbox, FALSE, FALSE, 5);

	button = ui_make_small_button (FALSE, FALSE, _("Clear"),
				       "_Clear", _("Clear the editor's\ncontents"));
	gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0);
	g_signal_connect (button, "clicked",
			  G_CALLBACK (sql_clear_clicked_cb), tconsole);

	button = ui_make_small_button (TRUE, FALSE, _("Variables"),
				       NULL, _("Show variables needed\nto execute SQL"));
	gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0);
	tconsole->priv->params_toggle = GTK_TOGGLE_BUTTON (button);
	g_signal_connect (button, "toggled",
			  G_CALLBACK (sql_variables_clicked_cb), tconsole);

	button = ui_make_small_button (FALSE, FALSE, _("Execute"),
				       "_Execute", _("Execute SQL in editor"));
	tconsole->priv->exec_button = button;
	gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0);
	g_signal_connect (button, "clicked",
			  G_CALLBACK (sql_execute_clicked_cb), tconsole);
	
	button = ui_make_small_button (FALSE, FALSE, _("Indent"),
				       NULL, _("Indent SQL in editor\n"
					       "and make the code more readable\n"
					       "(removes comments)"));
	tconsole->priv->indent_button = button;
	gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0);
	g_signal_connect (button, "clicked",
			  G_CALLBACK (sql_indent_clicked_cb), tconsole);

	button = ui_make_small_button (FALSE, TRUE, _("Favorite"),
				       NULL, _("Add SQL to favorite"));
	gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0);
	g_signal_connect (button, "clicked",
			  G_CALLBACK (sql_favorite_clicked_cb), tconsole);

	/* bottom paned for the results and history */
	hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_paned_pack2 (GTK_PANED (vpaned), hpaned, TRUE, FALSE);

	/* bottom left */
	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_paned_pack1 (GTK_PANED (hpaned), vbox, FALSE, FALSE);

	wid = gtk_label_new ("");
	str = g_strdup_printf ("<b>%s</b>", _("Execution history:"));
	gtk_label_set_markup (GTK_LABEL (wid), str);
	g_free (str);
	gtk_widget_set_halign (wid, GTK_ALIGN_START);
	gtk_box_pack_start (GTK_BOX (vbox), wid, FALSE, FALSE, 0);

	wid = query_editor_new ();
	tconsole->priv->history = QUERY_EDITOR (wid);
	query_editor_set_mode (tconsole->priv->history, QUERY_EDITOR_HISTORY);
	gtk_widget_set_size_request (wid, 200, -1);
	gtk_box_pack_start (GTK_BOX (vbox), wid, TRUE, TRUE, 6);
	g_signal_connect (wid, "changed",
			  G_CALLBACK (history_changed_cb), tconsole);

	bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0);
	gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END);

	button = ui_make_small_button (FALSE, FALSE, _("Copy"),
				       "_Copy", _("Copy selected history\nto editor"));
	gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0);
	g_signal_connect (button, "clicked",
			  G_CALLBACK (history_copy_clicked_cb), tconsole);
	tconsole->priv->history_copy_button = button;
	gtk_widget_set_sensitive (button, FALSE);

	button = ui_make_small_button (FALSE, FALSE, _("Clear"),
				       "_Clear", _("Clear history"));
	gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0);
	g_signal_connect (button, "clicked",
			  G_CALLBACK (history_clear_clicked_cb), tconsole);
	tconsole->priv->history_del_button = button;
	gtk_widget_set_sensitive (button, FALSE);

	/* bottom right */
	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
	gtk_paned_pack2 (GTK_PANED (hpaned), vbox, TRUE, FALSE);
	
	wid = gtk_label_new ("");
	str = g_strdup_printf ("<b>%s</b>", _("Execution Results:"));
	gtk_label_set_markup (GTK_LABEL (wid), str);
	g_free (str);
	gtk_widget_set_halign (wid, GTK_ALIGN_START);
	gtk_box_pack_start (GTK_BOX (vbox), wid, FALSE, FALSE, 0);

	wid = query_result_new (tconsole->priv->history);
	tconsole->priv->query_result = wid;
	gtk_box_pack_start (GTK_BOX (vbox), wid, TRUE, TRUE, 0);
	g_signal_connect (wid, "rerun-requested",
			  G_CALLBACK (rerun_requested_cb), tconsole);

	/* show everything */
        gtk_widget_show_all (vpaned);
	gtk_widget_hide (tconsole->priv->params_top);

	/* busy connection handling */
	connection_status_changed_cb (tconsole->priv->tcnc,
				      gda_connection_get_status (t_connection_get_cnc (tconsole->priv->tcnc)),
				      tconsole);

	g_signal_connect (tconsole->priv->tcnc, "status-changed",
			  G_CALLBACK (connection_status_changed_cb), tconsole);

	return (GtkWidget*) tconsole;
}
Beispiel #19
0
/**
 * Statistic Viewer's constructor
 *
 * This constructor is used to create StatisticViewerData data structure.
 * @return The Statistic viewer data created.
 */
StatisticViewerData *
gui_statistic(LttvPluginTab *ptab)
{
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;

  StatisticViewerData* statistic_viewer_data = g_new(StatisticViewerData,1);
  statistic_viewer_data->live_trace_count = 0;
  Tab *tab = ptab->tab;
  statistic_viewer_data->tab  = tab;
  statistic_viewer_data->ptab  = ptab;
 // statistic_viewer_data->stats  =
 //         lttvwindow_get_traceset_stats(statistic_viewer_data->tab);
 // statistic_viewer_data->calculate_stats = 
 //   statistic_insert_traceset_stats((void *)statistic_viewer_data->stats);

  lttvwindow_register_traceset_notify(statistic_viewer_data->tab,
                                      statistic_traceset_changed,
                                      statistic_viewer_data);
  statistic_viewer_data->statistic_hash = g_hash_table_new_full(g_str_hash,
                                                  g_str_equal,
                                                  statistic_destroy_hash_key,
                                                  NULL);

  statistic_viewer_data->hpaned_v  = gtk_hpaned_new();
  statistic_viewer_data->store_m = gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING);
  statistic_viewer_data->tree_v  = 
    gtk_tree_view_new_with_model (
        GTK_TREE_MODEL (statistic_viewer_data->store_m));
  g_object_unref (G_OBJECT (statistic_viewer_data->store_m));

  // Setup the selection handler
  statistic_viewer_data->select_c = gtk_tree_view_get_selection (GTK_TREE_VIEW (statistic_viewer_data->tree_v));
  gtk_tree_selection_set_mode (statistic_viewer_data->select_c, GTK_SELECTION_SINGLE);
  g_signal_connect (G_OBJECT (statistic_viewer_data->select_c), "changed",
        G_CALLBACK (tree_selection_changed_cb),
        statistic_viewer_data);

  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("Statistic Name",
                 renderer,
                 "text", NAME_COLUMN,
                 NULL);
  gtk_tree_view_column_set_alignment (column, 0.0);
  //  gtk_tree_view_column_set_fixed_width (column, 45);
  gtk_tree_view_append_column (GTK_TREE_VIEW (statistic_viewer_data->tree_v), column);


  gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (statistic_viewer_data->tree_v), FALSE);

  statistic_viewer_data->scroll_win_tree = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(statistic_viewer_data->scroll_win_tree), 
         GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);

  gtk_container_add (GTK_CONTAINER (statistic_viewer_data->scroll_win_tree), statistic_viewer_data->tree_v);
  gtk_paned_pack1(GTK_PANED(statistic_viewer_data->hpaned_v),statistic_viewer_data->scroll_win_tree, TRUE, FALSE);
  gtk_paned_set_position(GTK_PANED(statistic_viewer_data->hpaned_v), 160);

  statistic_viewer_data->scroll_win_text = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(statistic_viewer_data->scroll_win_text), 
         GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);

  statistic_viewer_data->text_v = gtk_text_view_new ();
  
  gtk_text_view_set_editable(GTK_TEXT_VIEW(statistic_viewer_data->text_v),FALSE);
  gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(statistic_viewer_data->text_v),FALSE);
  gtk_container_add (GTK_CONTAINER (statistic_viewer_data->scroll_win_text), statistic_viewer_data->text_v);
  gtk_paned_pack2(GTK_PANED(statistic_viewer_data->hpaned_v), statistic_viewer_data->scroll_win_text, TRUE, FALSE);

  gtk_container_set_border_width(
      GTK_CONTAINER(statistic_viewer_data->hpaned_v), 1);
  
  gtk_widget_show(statistic_viewer_data->scroll_win_tree);
  gtk_widget_show(statistic_viewer_data->scroll_win_text);
  gtk_widget_show(statistic_viewer_data->tree_v);
  gtk_widget_show(statistic_viewer_data->text_v);
  gtk_widget_show(statistic_viewer_data->hpaned_v);

  g_object_set_data_full(
      G_OBJECT(guistatistic_get_widget(statistic_viewer_data)),
      "statistic_viewer_data",
      statistic_viewer_data,
      (GDestroyNotify)gui_statistic_destructor);

  /* Add the object's information to the module's array */
  g_statistic_viewer_data_list = g_slist_append(
      g_statistic_viewer_data_list,
      statistic_viewer_data);

  request_background_data(statistic_viewer_data);
 
  return statistic_viewer_data;
}
static void
task_shell_content_constructed (GObject *object)
{
	ETaskShellContent *task_shell_content;
	EShellView *shell_view;
	EShellContent *shell_content;
	EShellTaskbar *shell_taskbar;
	ECalModel *model;
	GalViewInstance *view_instance;
	GtkTargetList *target_list;
	GtkTargetEntry *targets;
	GtkWidget *container;
	GtkWidget *widget;
	gint n_targets;

	task_shell_content = E_TASK_SHELL_CONTENT (object);

	/* Chain up to parent's constructed() method. */
	G_OBJECT_CLASS (e_task_shell_content_parent_class)->constructed (object);

	model = e_cal_base_shell_content_get_model (E_CAL_BASE_SHELL_CONTENT (task_shell_content));

	shell_content = E_SHELL_CONTENT (object);
	shell_view = e_shell_content_get_shell_view (shell_content);
	shell_taskbar = e_shell_view_get_shell_taskbar (shell_view);

	/* Build content widgets. */

	container = GTK_WIDGET (object);

	widget = e_paned_new (GTK_ORIENTATION_VERTICAL);
	gtk_container_add (GTK_CONTAINER (container), widget);
	task_shell_content->priv->paned = g_object_ref (widget);
	gtk_widget_show (widget);

	e_binding_bind_property (
		object, "orientation",
		widget, "orientation",
		G_BINDING_SYNC_CREATE);

	container = task_shell_content->priv->paned;

	widget = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (
		GTK_SCROLLED_WINDOW (widget),
		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE);
	gtk_widget_show (widget);

	container = widget;

	widget = e_task_table_new (shell_view, model);
	gtk_container_add (GTK_CONTAINER (container), widget);
	task_shell_content->priv->task_table = g_object_ref (widget);
	gtk_widget_show (widget);

	container = task_shell_content->priv->paned;

	widget = e_cal_component_preview_new ();
	gtk_widget_show (widget);

	g_signal_connect_swapped (
		widget, "status-message",
		G_CALLBACK (e_shell_taskbar_set_message),
		shell_taskbar);

	widget = e_preview_pane_new (E_WEB_VIEW (widget));
	gtk_paned_pack2 (GTK_PANED (container), widget, FALSE, FALSE);
	task_shell_content->priv->preview_pane = g_object_ref (widget);
	gtk_widget_show (widget);

	e_binding_bind_property (
		object, "preview-visible",
		widget, "visible",
		G_BINDING_SYNC_CREATE);

	target_list = gtk_target_list_new (NULL, 0);
	e_target_list_add_calendar_targets (target_list, 0);
	targets = gtk_target_table_new_from_list (target_list, &n_targets);

	e_table_drag_source_set (
		E_TABLE (task_shell_content->priv->task_table),
		GDK_BUTTON1_MASK, targets, n_targets,
		GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_ASK);

	gtk_target_table_free (targets, n_targets);
	gtk_target_list_unref (target_list);

	g_signal_connect_swapped (
		task_shell_content->priv->task_table, "table-drag-data-get",
		G_CALLBACK (task_shell_content_table_drag_data_get_cb),
		object);

	g_signal_connect_swapped (
		task_shell_content->priv->task_table, "table-drag-data-delete",
		G_CALLBACK (task_shell_content_table_drag_data_delete_cb),
		object);

	g_signal_connect_swapped (
		task_shell_content->priv->task_table, "cursor-change",
		G_CALLBACK (task_shell_content_cursor_change_cb),
		object);

	g_signal_connect_swapped (
		task_shell_content->priv->task_table, "selection-change",
		G_CALLBACK (task_shell_content_selection_change_cb),
		object);

	e_signal_connect_notify (
		task_shell_content->priv->task_table, "notify::is-editing",
		G_CALLBACK (task_shell_content_is_editing_changed_cb), shell_view);

	g_signal_connect_swapped (
		model, "model-row-changed",
		G_CALLBACK (task_shell_content_model_row_changed_cb), object);

	/* Prepare the view instance. */

	view_instance = e_shell_view_new_view_instance (shell_view, NULL);
	g_signal_connect_swapped (
		view_instance, "display-view",
		G_CALLBACK (task_shell_content_display_view_cb),
		object);
	e_shell_view_set_view_instance (shell_view, view_instance);
	g_object_unref (view_instance);
}
Beispiel #21
0
static void
viewer_init (Viewer *viewer)
{
    viewer->renderers = g_ptr_array_new();
    viewer->renderers_sorted = g_ptr_array_new();
    viewer->renderers_sorted_with_controls = g_ptr_array_new();
    viewer->event_handlers = g_ptr_array_new();
    viewer->event_handlers_sorted = g_ptr_array_new();
    viewer->modes = g_ptr_array_new();

    viewer->prettier_flag = (getenv("DGC_VIEWER_PRETTIER") != NULL && 
                             atoi(getenv("DGC_VIEWER_PRETTIER"))>0);;
    printf("DGC_VIEWER_PRETTIER: %d\n", viewer->prettier_flag);

    viewer->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(viewer->window), "Viewer");
    gtk_window_set_resizable(GTK_WINDOW(viewer->window), TRUE);
    gtk_window_set_default_size(GTK_WINDOW(viewer->window), 800, 540);

    GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(viewer->window), vbox);
    
    make_menus(viewer, vbox);

    viewer->tips = gtk_tooltips_new ();
    make_toolbar(viewer, vbox);

    GtkWidget *hpaned = gtk_hpaned_new();
    gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0);

    GtkWidget *gl_box = gtk_event_box_new();
    gtk_paned_pack1(GTK_PANED(hpaned), gl_box, TRUE, TRUE);

    GtkWidget *controls_align = gtk_alignment_new(.5, .5, 1, 1);
    gtk_paned_pack2(GTK_PANED(hpaned), controls_align, FALSE, TRUE);

    gtk_paned_set_position(GTK_PANED(hpaned), 560);

    GtkWidget *controls_scroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_container_add(GTK_CONTAINER(controls_align), controls_scroll);

    GtkWidget *controls_view = gtk_viewport_new(NULL, NULL);
    gtk_container_add(GTK_CONTAINER(controls_scroll), controls_view);

    viewer->controls_box = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(controls_view), viewer->controls_box);

    viewer->status_bar = gtk_statusbar_new();
    gtk_box_pack_start(GTK_BOX(vbox), viewer->status_bar, FALSE, FALSE, 0);
    viewer_set_status_bar_message(viewer, "Ready");

    // create the aspect area to maintain a 1:1 aspect ratio
    viewer->gl_area = GTKU_GL_DRAWING_AREA (gtku_gl_drawing_area_new (FALSE));
    gtk_widget_set_events (GTK_WIDGET (viewer->gl_area), 
            GDK_LEAVE_NOTIFY_MASK |
            GDK_BUTTON_PRESS_MASK | 
            GDK_BUTTON_RELEASE_MASK | 
            GDK_POINTER_MOTION_MASK);

    gtk_container_add (GTK_CONTAINER (gl_box), GTK_WIDGET (viewer->gl_area));
    gtk_widget_show (GTK_WIDGET (viewer->gl_area));

    g_signal_connect (G_OBJECT (viewer->gl_area), "configure-event",
            G_CALLBACK (on_gl_configure), viewer);
    g_signal_connect (G_OBJECT (viewer->gl_area), "expose-event",
            G_CALLBACK (on_gl_expose), viewer);
    g_signal_connect (G_OBJECT (viewer->gl_area), "button-press-event",
            G_CALLBACK (on_button_press), viewer);
    g_signal_connect (G_OBJECT (viewer->gl_area), "button-release-event",
            G_CALLBACK (on_button_release), viewer);
    g_signal_connect (G_OBJECT (viewer->gl_area), "motion-notify-event",
            G_CALLBACK (on_motion_notify), viewer);
    g_signal_connect (G_OBJECT (viewer->gl_area), "scroll-event",
            G_CALLBACK (on_scroll_notify), viewer);

    g_signal_connect (G_OBJECT (viewer->window), "key_press_event",
		      G_CALLBACK (on_main_window_key_press_event), viewer);

    g_signal_connect (G_OBJECT (viewer->window), "delete_event",
		      G_CALLBACK(gtk_main_quit), NULL);
    g_signal_connect (G_OBJECT (viewer->window), "delete_event",
            G_CALLBACK (gtk_widget_hide_on_delete), NULL);

    g_signal_connect (G_OBJECT (viewer->window), "destroy_event",
		      G_CALLBACK(gtk_main_quit), NULL);

    ////////////////////////////////////////////////////////////////////
    // Create plugins menu


    // plugins will be inserted here as add_plugin is called
 
    gtk_widget_show_all(viewer->window);

    DefaultViewHandler *dvh = default_view_handler_new(viewer);
    viewer->default_view_handler = &dvh->vhandler;

    viewer_request_redraw(viewer);
}
static void
rb_iradio_source_constructed (GObject *object)
{
	RBIRadioSource *source;
	RBShell *shell;
	GtkAction *action;
	GSettings *settings;
	GtkUIManager *ui_manager;
	GtkWidget *grid;
	GtkWidget *paned;
	RBSourceToolbar *toolbar;
	gint size;
	GdkPixbuf *pixbuf;

	RB_CHAIN_GOBJECT_METHOD (rb_iradio_source_parent_class, constructed, object);
	source = RB_IRADIO_SOURCE (object);

	paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);

	g_object_get (source, "shell", &shell, NULL);
	g_object_get (shell,
		      "db", &source->priv->db,
		      "shell-player", &source->priv->player,
		      "ui-manager", &ui_manager,
		      NULL);
	g_object_unref (shell);

	gtk_icon_size_lookup (RB_SOURCE_ICON_SIZE, &size, NULL);
	pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
					   IRADIO_SOURCE_ICON,
					   size,
					   0, NULL);
	g_object_set (source, "pixbuf", pixbuf, NULL);
	if (pixbuf != NULL) {
		g_object_unref (pixbuf);
	}

	settings = g_settings_new ("org.gnome.rhythmbox.plugins.iradio");
	if (g_settings_get_boolean (settings, "initial-stations-loaded") == FALSE) {
		GObject *plugin;
		char *file;

		g_object_get (source, "plugin", &plugin, NULL);
		file = rb_find_plugin_data_file (plugin, "iradio-initial.xspf");
		if (file != NULL) {
			char *uri = g_filename_to_uri (file, NULL, NULL);
			if (uri != NULL) {
				rb_iradio_source_add_from_playlist (source, uri);
				g_free (uri);

				g_settings_set_boolean (settings, "initial-stations-loaded", TRUE);
			}
		}
		g_free (file);
		g_object_unref (plugin);
	}

	source->priv->action_group = _rb_display_page_register_action_group (RB_DISPLAY_PAGE (source),
									     "IRadioActions",
									     rb_iradio_source_actions,
									     G_N_ELEMENTS (rb_iradio_source_actions),
									     source);

	action = gtk_action_group_get_action (source->priv->action_group,
                                              "MusicNewInternetRadioStation");
        /* Translators: this is the toolbar button label for 
           New Internet Radio Station action. */
        g_object_set (action, "short-label", C_("Radio", "Add"), NULL);


	/* set up stations view */
	source->priv->stations = rb_entry_view_new (source->priv->db, G_OBJECT (source->priv->player),
						    FALSE, FALSE);

	rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_TITLE, TRUE);
	rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_GENRE, FALSE);
/* 	rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_QUALITY, FALSE); */
	rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_RATING, FALSE);
/*	rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_PLAY_COUNT, FALSE);*/
	rb_entry_view_append_column (source->priv->stations, RB_ENTRY_VIEW_COL_LAST_PLAYED, FALSE);
	g_signal_connect_object (source->priv->stations,
				 "notify::sort-order",
				 G_CALLBACK (rb_iradio_source_songs_view_sort_order_changed_cb),
				 source, 0);

	/* set up drag and drop for the song tree view.
	 * we don't use RBEntryView's DnD support because it does too much.
	 * we just want to be able to drop stations in to add them.
	 */
	g_signal_connect_object (source->priv->stations,
				 "drag_data_received",
				 G_CALLBACK (stations_view_drag_data_received_cb),
				 source, 0);
	gtk_drag_dest_set (GTK_WIDGET (source->priv->stations),
			   GTK_DEST_DEFAULT_ALL,
			   stations_view_drag_types, 2,
			   GDK_ACTION_COPY | GDK_ACTION_MOVE);

	g_signal_connect_object (source->priv->stations, "show_popup",
				 G_CALLBACK (rb_iradio_source_songs_show_popup_cb), source, 0);

	/* set up genre entry view */
	source->priv->genres = rb_property_view_new (source->priv->db,
						     RHYTHMDB_PROP_GENRE,
						     _("Genre"));
	gtk_widget_show_all (GTK_WIDGET (source->priv->genres));
	gtk_widget_set_no_show_all (GTK_WIDGET (source->priv->genres), TRUE);
	g_signal_connect_object (source->priv->genres,
				 "property-selected",
				 G_CALLBACK (genre_selected_cb),
				 source, 0);
	g_signal_connect_object (source->priv->genres,
				 "property-selection-reset",
				 G_CALLBACK (genre_selection_reset_cb),
				 source, 0);

	g_object_set (source->priv->genres, "vscrollbar_policy",
		      GTK_POLICY_AUTOMATIC, NULL);

	gtk_paned_pack1 (GTK_PANED (paned), GTK_WIDGET (source->priv->genres), FALSE, FALSE);
	gtk_paned_pack2 (GTK_PANED (paned), GTK_WIDGET (source->priv->stations), TRUE, FALSE);

	/* set up toolbar */
	toolbar = rb_source_toolbar_new (RB_SOURCE (source), ui_manager);
	rb_source_toolbar_add_search_entry (toolbar, NULL, _("Search your internet radio stations"));

	grid = gtk_grid_new ();
	gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
	gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
	gtk_widget_set_margin_top (GTK_WIDGET (grid), 6);
	gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (toolbar), 0, 0, 1, 1);
	gtk_grid_attach (GTK_GRID (grid), paned, 0, 1, 1, 1);

	gtk_container_add (GTK_CONTAINER (source), grid);

	rb_source_bind_settings (RB_SOURCE (source),
				 GTK_WIDGET (source->priv->stations),
				 paned,
				 GTK_WIDGET (source->priv->genres));

	gtk_widget_show_all (GTK_WIDGET (source));

	g_signal_connect_object (source->priv->player, "playing-source-changed",
				 G_CALLBACK (playing_source_changed_cb),
				 source, 0);

	source->priv->default_search = rb_iradio_source_search_new ();

	rb_iradio_source_do_query (source);
}
Beispiel #23
0
static void
gedit_dict_panel_draw (GeditDictPanel *panel)
{
	GtkWidget  *vbox;
	GtkWidget  *hbox;
	
	vbox = gtk_vbox_new (FALSE, 6);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
	gtk_widget_show (vbox);
 
	hbox = gtk_hbox_new (FALSE, 12);
	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
	gtk_widget_show (hbox);
	
	/*
	 * Look up Button
	 */
	panel->priv->button = gtk_button_new_with_mnemonic (_("Look _up:"));
	g_signal_connect(panel->priv->button, "clicked",
				 G_CALLBACK (gedit_dict_panel_entry_activate_cb),
				 panel);
	gtk_button_set_relief (GTK_BUTTON (panel->priv->button), GTK_RELIEF_NONE);
	gtk_box_pack_start (GTK_BOX (hbox), panel->priv->button, FALSE, FALSE, 0);
 	gtk_widget_show(panel->priv->button);
	
	/*
	 * Entry
	 */
	panel->priv->entry = gtk_entry_new ();
	if (panel->priv->word)
		gtk_entry_set_text (GTK_ENTRY (panel->priv->entry), panel->priv->word);
  
	g_signal_connect (panel->priv->entry, "activate",
				  G_CALLBACK (gedit_dict_panel_entry_activate_cb),
				  panel);
	gtk_box_pack_start (GTK_BOX (hbox), panel->priv->entry, TRUE, TRUE, 0);
	gtk_widget_show (panel->priv->entry);


	/*
	 * Defbox
	 */
	panel->priv->defbox = gdict_defbox_new ();
	if (panel->priv->context)
		gdict_defbox_set_context (GDICT_DEFBOX (panel->priv->defbox),
					  panel->priv->context);
	g_signal_connect(panel->priv->defbox, "link-clicked",
			 G_CALLBACK(gedit_dict_panel_link_clicked), panel);
	
	gtk_container_add (GTK_CONTAINER (vbox), panel->priv->defbox);
	gtk_widget_show (panel->priv->defbox);
	
	panel->priv->sidebar = gdict_sidebar_new ();
	g_signal_connect (panel->priv->sidebar, "page-changed",
			  G_CALLBACK (sidebar_page_changed_cb),
			  panel);

	/*
	 * Paned
	 */
	panel->priv->paned = GTK_PANED(gtk_vpaned_new());
	gtk_box_pack_start (GTK_BOX (panel), GTK_WIDGET(panel->priv->paned), TRUE, TRUE, 0);
	gtk_paned_pack1 (panel->priv->paned, vbox, FALSE, TRUE);
	gtk_paned_pack2 (panel->priv->paned, panel->priv->sidebar, TRUE, TRUE);
	gtk_widget_show (GTK_WIDGET(panel->priv->paned));
	
	g_signal_connect(panel->priv->paned, "notify::position",
			 G_CALLBACK(store_position), NULL);
	
	
	/*
	 * Speller
	 */
	panel->priv->speller = gdict_speller_new ();
	if (panel->priv->context)
		gdict_speller_set_context (GDICT_SPELLER (panel->priv->speller),
					   panel->priv->context);
	g_signal_connect (panel->priv->speller, "word-activated",
			  G_CALLBACK (speller_word_activated_cb),
			  panel);
  
	gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
				GDICT_SIDEBAR_SPELLER_PAGE,
				_("Similar words"),
				panel->priv->speller);
	gtk_widget_show (panel->priv->speller);

	/*
	 * db chooser
	 */
  	panel->priv->db_chooser = gdict_database_chooser_new ();
	if (panel->priv->context)
		gdict_database_chooser_set_context (GDICT_DATABASE_CHOOSER (panel->priv->db_chooser),
						    panel->priv->context);
	g_signal_connect (panel->priv->db_chooser, "database-activated",
			  G_CALLBACK (database_activated_cb),
			  panel);
	gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
				GDICT_SIDEBAR_DATABASES_PAGE,
				_("Available dictionaries"),
				panel->priv->db_chooser);
	gtk_widget_show (panel->priv->db_chooser);

	/*
	 * Strategy chooser
	 */
  	panel->priv->strat_chooser = gdict_strategy_chooser_new ();
	if (panel->priv->context)
		gdict_strategy_chooser_set_context (GDICT_STRATEGY_CHOOSER (panel->priv->strat_chooser),
						    panel->priv->context);
	g_signal_connect (panel->priv->strat_chooser, "strategy-activated",
			  G_CALLBACK (strategy_activated_cb),
			  panel);
	gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
				GDICT_SIDEBAR_STRATEGIES_PAGE,
				_("Available strategies"),
				panel->priv->strat_chooser);
	gtk_widget_show (panel->priv->strat_chooser);

	gtk_widget_show (panel->priv->sidebar);
	
	
}
Beispiel #24
0
GtkWidget *
gtkam_main_new (void)
{
    GtkamMain *m;
    GdkPixbuf *pixbuf;
    GtkActionGroup *action_group;
    GtkUIManager *ui_manager;
    GtkAccelGroup *accel_group;
    GtkWidget *widget, *vbox, *scrolled, *hpaned, *t;

    m = g_object_new (GTKAM_TYPE_MAIN, NULL);
    gtk_window_set_title (GTK_WINDOW (m), PACKAGE);
    pixbuf = gdk_pixbuf_new_from_file (IMAGE_DIR "/gtkam-camera.png", NULL);
    if (pixbuf != NULL) {
        gtk_window_set_icon (GTK_WINDOW (m), pixbuf);
        gdk_pixbuf_unref (pixbuf);
    }

    m->priv->view_thumbs = TRUE;

    vbox = gtk_vbox_new (FALSE, 1);
    gtk_widget_show (vbox);
    gtk_container_add (GTK_CONTAINER (m), vbox);

    /* Menu */
    action_group = gtk_action_group_new ("MenuActions");
#ifdef GETTEXT_PACKAGE
    gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
#endif
    gtk_action_group_add_actions (action_group, entries, G_N_ELEMENTS (entries), m);
    gtk_action_group_add_toggle_actions (action_group, toggle_entries, G_N_ELEMENTS (toggle_entries), m);

    ui_manager = gtk_ui_manager_new ();
    gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);

    accel_group = gtk_ui_manager_get_accel_group (ui_manager);
    gtk_window_add_accel_group (GTK_WINDOW (m), accel_group);

    gtk_ui_manager_add_ui_from_string(ui_manager, ui_description, -1, NULL);
    widget = gtk_ui_manager_get_widget (ui_manager, "/MainMenu");
    gtk_widget_show (widget);
    gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
    m->priv->ui_manager = GTK_UI_MANAGER (ui_manager);

    /* Toolbar */
    t = gtk_ui_manager_get_widget (ui_manager, "/MainToolbar");
    gtk_toolbar_set_style (GTK_TOOLBAR (t), GTK_TOOLBAR_BOTH);
    gtk_box_pack_start (GTK_BOX (vbox), t, FALSE, FALSE, 0);

    /*
     * Context information
     */
    m->priv->status = gtk_vbox_new (FALSE, 0);
    gtk_widget_show (m->priv->status);
    gtk_box_pack_end (GTK_BOX (vbox), m->priv->status, FALSE, FALSE, 0);

    /*
     * Main content
     */
    hpaned = gtk_hpaned_new ();
    gtk_widget_show (hpaned);
    gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (hpaned), 2);
    gtk_paned_set_position (GTK_PANED (hpaned), 200);

    /*
     * Left
     */
    scrolled = gtk_scrolled_window_new (NULL, NULL);
    gtk_widget_show (scrolled);
    gtk_paned_pack1 (GTK_PANED (hpaned), scrolled, TRUE, TRUE);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
                                    GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

    m->priv->tree = gtkam_tree_new ();
    gtk_widget_show (m->priv->tree);
    gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled),
                                           m->priv->tree);
    g_signal_connect (G_OBJECT (m->priv->tree), "folder_selected",
                      G_CALLBACK (on_folder_selected), m);
    g_signal_connect (G_OBJECT (m->priv->tree), "folder_unselected",
                      G_CALLBACK (on_folder_unselected), m);
    g_signal_connect (G_OBJECT (m->priv->tree), "new_status",
                      G_CALLBACK (on_new_status), m);
    g_signal_connect (G_OBJECT (m->priv->tree), "new_error",
                      G_CALLBACK (on_tree_new_error), m);
    g_signal_connect (G_OBJECT (m->priv->tree), "file_added",
                      G_CALLBACK (on_tree_file_added), m);
    g_signal_connect (G_OBJECT (m->priv->tree), "new_dialog",
                      G_CALLBACK (on_new_dialog), m);

    /*
     * Right
     */
    scrolled = gtk_scrolled_window_new (NULL, NULL);
    gtk_widget_show (scrolled);
    gtk_paned_pack2 (GTK_PANED (hpaned), scrolled, TRUE, TRUE);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
                                    GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

    m->priv->list = gtkam_list_new ();
    gtk_widget_show (m->priv->list);
    gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled),
                                           m->priv->list);
    g_signal_connect (G_OBJECT (m->priv->list), "file_selected",
                      G_CALLBACK (on_file_selected), m);
    g_signal_connect (G_OBJECT (m->priv->list), "file_unselected",
                      G_CALLBACK (on_file_unselected), m);
    g_signal_connect (G_OBJECT (m->priv->list), "new_status",
                      G_CALLBACK (on_new_status), m);
    g_signal_connect (G_OBJECT (m->priv->list), "new_dialog",
                      G_CALLBACK (on_new_dialog), m);

    gtkam_main_update_sensitivity (m);

    return (GTK_WIDGET (m));
}
Beispiel #25
0
static void main_window_fill_panes(void)
{
	GtkWidget *box;
	GtkWidget *box2;
	GtkWidget *chkOnlyCurFileFuncs;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;

	//Commented out as panes aren't used yet AJ 2003-01-21 TODO: replace old style code with new main_window.* code
	/*notebook_manager = gtk_notebook_new ();
	gtk_widget_show (notebook_manager);
	gtk_paned_pack1 (GTK_PANED (hpaned1), notebook_manager, FALSE, TRUE);
	gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook_manager), GTK_POS_BOTTOM);
	gtk_widget_set_usize(notebook_manager,200,400);*/

	box = gtk_vbox_new(FALSE, 0);
	gtk_widget_show(box);
	gtk_paned_pack1 (GTK_PANED (main_window.main_horizontal_pane), box, FALSE, TRUE);
	
	//add checkbox to show only current file's classes
	//the signals to be checked for the check box are onclick of the checkbox 
	//and the on change of the file.
	//Close button for the side bar
	GtkWidget *hbox;
	hbox = gtk_hbox_new(FALSE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(hbox), 0);
	main_window.close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
	gtk_misc_set_padding(GTK_MISC(main_window.close_image), 0, 0);
	main_window.close_sidebar_button = gtk_button_new();
	gtk_widget_set_tooltip_text(main_window.close_sidebar_button, _("Close class Browser"));
	gtk_button_set_image(GTK_BUTTON(main_window.close_sidebar_button), main_window.close_image);
	gtk_button_set_relief(GTK_BUTTON(main_window.close_sidebar_button), GTK_RELIEF_NONE);
	gtk_button_set_focus_on_click(GTK_BUTTON(main_window.close_sidebar_button), FALSE);
	gtk_signal_connect(GTK_OBJECT(main_window.close_sidebar_button), "clicked", G_CALLBACK (classbrowser_show_hide),NULL);
	gtk_widget_show(main_window.close_image);
	gtk_widget_show(main_window.close_sidebar_button);
	//
	main_window.chkOnlyCurFileFuncs = gtk_check_button_new_with_label(_("Parse only current file")); 
	gtk_widget_show (main_window.chkOnlyCurFileFuncs);
	gtk_box_pack_start(GTK_BOX(hbox), main_window.chkOnlyCurFileFuncs, FALSE, FALSE, 10);
//	gtk_box_pack_start(GTK_BOX(box), main_window.chkOnlyCurFileFuncs, FALSE, FALSE, 10);
	gtk_box_pack_start(GTK_BOX(hbox), main_window.close_sidebar_button, FALSE, FALSE, 0);
	gtk_widget_show(hbox);	
	gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 10);
	g_signal_connect (G_OBJECT (main_window.chkOnlyCurFileFuncs), "clicked",
						G_CALLBACK (on_parse_current_click), NULL);

	main_window.scrolledwindow3 = gtk_scrolled_window_new (NULL, NULL);
	gtk_widget_show (main_window.scrolledwindow3);
	gtk_box_pack_start(GTK_BOX(box), main_window.scrolledwindow3, TRUE, TRUE, 0);
	gtk_paned_pack1 (GTK_PANED (main_window.main_horizontal_pane), main_window.scrolledwindow3, FALSE, TRUE);

	box2 = gtk_hbox_new(FALSE, 0);
	gtk_widget_show(box2);
	main_window.treeviewlabel = gtk_label_new(_("FILE: "));
	gtk_label_set_justify(GTK_LABEL(main_window.treeviewlabel), GTK_JUSTIFY_LEFT);
	gtk_widget_show(main_window.treeviewlabel);
	gtk_box_pack_start(GTK_BOX(box2), main_window.treeviewlabel, FALSE, FALSE, 0);
	gtk_box_pack_end(GTK_BOX(box), box2, FALSE, FALSE, 4);
	//gtk_container_add (GTK_CONTAINER (notebook_manager), main_window.scrolledwindow3);

	main_window.classtreestore = gtk_tree_store_new (N_COLUMNS, G_TYPE_STRING,
															 G_TYPE_INT, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT);
	//enable sorting of the columns
	classbrowser_set_sortable(main_window.classtreestore);

	main_window.classtreeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (main_window.classtreestore));
	gtk_widget_show (main_window.classtreeview);
	gtk_container_add (GTK_CONTAINER (main_window.scrolledwindow3), main_window.classtreeview);

	main_window.classtreeselect = gtk_tree_view_get_selection (GTK_TREE_VIEW (main_window.classtreeview));
	gtk_tree_selection_set_mode (main_window.classtreeselect, GTK_SELECTION_SINGLE);
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes (_("Name"),
					 renderer, "text", NAME_COLUMN, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (main_window.classtreeview), column);

	/*label1 = gtk_label_new ("Functions");
	gtk_widget_show (label1);
	gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook_manager), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook_manager), 0), label1);
	gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT);
	 
	notebook_manager_functions_page = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (notebook_manager_functions_page);
	gtk_container_add (GTK_CONTAINER (notebook_manager), notebook_manager_functions_page);

	label2 = gtk_label_new ("Files");
	gtk_widget_show (label2);
	gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook_manager), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook_manager), 1), label2);
	gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_LEFT);

	notebook_manager_files_page = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (notebook_manager_files_page);
	gtk_container_add (GTK_CONTAINER (notebook_manager), notebook_manager_files_page);

	label3 = gtk_label_new ("Help");
	gtk_widget_show (label3);
	gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook_manager), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook_manager), 2), label3);
	gtk_label_set_justify (GTK_LABEL (label3), GTK_JUSTIFY_LEFT);
	*/
	main_window.scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
	gtk_paned_pack2 (GTK_PANED (main_window.main_vertical_pane), main_window.scrolledwindow1, FALSE, TRUE);

	main_window.lint_view = gtk_tree_view_new ();
	gtk_container_add (GTK_CONTAINER (main_window.scrolledwindow1), main_window.lint_view);
	main_window.lint_renderer = gtk_cell_renderer_text_new ();
	main_window.lint_column = gtk_tree_view_column_new_with_attributes (_("Syntax Check Output"),
								main_window.lint_renderer,
								"text", 0,
								NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (main_window.lint_view), main_window.lint_column);
	//gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (main_window.lint_view), FALSE);
	gtk_widget_set_usize(main_window.lint_view,80,80);
	main_window.lint_select = gtk_tree_view_get_selection (GTK_TREE_VIEW (main_window.lint_view));
	gtk_tree_selection_set_mode (main_window.lint_select, GTK_SELECTION_SINGLE);
	g_signal_connect (G_OBJECT (main_window.lint_select), "changed",
						G_CALLBACK (lint_row_activated), NULL);

	main_window.notebook_editor = gtk_notebook_new ();
	gtk_notebook_set_scrollable(GTK_NOTEBOOK(main_window.notebook_editor), TRUE);
	//GTK_WIDGET_UNSET_FLAGS (main_window.notebook_editor, GTK_CAN_FOCUS | GTK_RECEIVES_DEFAULT);
	// Fix to scrollable list of tabs, however it then messes up grabbing of focus
	// Hence the focus-tab event (which GTK doesn't seem to recognise
	GTK_WIDGET_UNSET_FLAGS (main_window.notebook_editor, GTK_RECEIVES_DEFAULT);
	gtk_widget_show (main_window.notebook_editor);
	gtk_paned_pack2 (GTK_PANED (main_window.main_horizontal_pane), main_window.notebook_editor, TRUE, TRUE);
	gtk_widget_set_usize(main_window.notebook_editor,400,400);
	g_signal_connect (G_OBJECT (main_window.notebook_editor), "switch_page", GTK_SIGNAL_FUNC (on_notebook_switch_page), NULL);
	g_signal_connect (G_OBJECT (main_window.notebook_editor), "focus-tab", GTK_SIGNAL_FUNC (on_notebook_focus_tab), NULL);
}
int
main (int    argc,
      char **argv)
{
  GtkWidget *window, *embed, *vbox, *menubar, *vpaned, *textpanel;
  ClutterActor *stage, *grid_view;

  setlocale (LC_ALL, "");
  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);

  g_thread_init (NULL);
  profile_timer = g_timer_new ();

  clutter_init (&argc, &argv);
  gtk_init(&argc, &argv);
  g_set_application_name("GNOME Social Zone");
  
    mx_style_load_from_file (mx_style_get_default (),
                           THEMEDIR "/panel.css", NULL);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (window), _("GNOME Social Zone"));
    gtk_window_set_icon_name (GTK_WINDOW (window), "gnome-social-zone");
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_main_quit),
                    NULL);
                    
    vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(window), vbox);
    
    menubar = get_menubar_menu (GTK_WIDGET(window));
    vpaned = gtk_vpaned_new ();
    
    gtk_box_pack_start(GTK_BOX (vbox), menubar, FALSE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX (vbox), vpaned, TRUE, TRUE, 0);

    embed = gtk_clutter_embed_new ();
    
    gtk_paned_pack1 (GTK_PANED (vpaned), GTK_WIDGET(embed), FALSE, FALSE);
    
    textpanel = get_text_panel();

    gtk_paned_pack2 (GTK_PANED (vpaned), textpanel, TRUE, TRUE);

    stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (embed));
    clutter_actor_realize (stage);
    
    grid_view = g_object_new (PENGE_TYPE_GRID_VIEW,
                              NULL);
    
    clutter_container_add_actor (CLUTTER_CONTAINER (stage),
                                 (ClutterActor *)grid_view);
    clutter_actor_set_size ((ClutterActor *)grid_view, 1016, 536);
    gtk_widget_set_size_request (embed, 1016, 536);
    
    clutter_actor_show_all (stage);
    
    gtk_widget_show_all (GTK_WIDGET(window));
    
  g_signal_connect_after (stage,
                          "paint",
                          (GCallback)_stage_paint_cb,
                          NULL);

  g_message (G_STRLOC ": PROFILE: Main loop started: %f",
             g_timer_elapsed (profile_timer, NULL));
  gtk_main();

  return 0;
}
Beispiel #27
0
static void
setup_gtk (state_t *self)
{
    self->window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL));
    gtk_window_set_title(self->window, "Camview");
    gtk_window_set_resizable(self->window, TRUE);
    gtk_window_set_default_size(self->window, 1000, 540);
    gtk_signal_connect (GTK_OBJECT (self->window), "delete_event", 
            GTK_SIGNAL_FUNC (gtk_main_quit), NULL);

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

    // menu bar
    GtkWidget *menubar = gtk_menu_bar_new ();
    gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, TRUE, 0);
    
    // file menu
    GtkWidget *file_menu_item = gtk_menu_item_new_with_mnemonic ("_File");
    gtk_menu_bar_append (GTK_MENU_BAR (menubar), file_menu_item);
    GtkWidget *file_menu = gtk_menu_new ();
    gtk_menu_item_set_submenu (GTK_MENU_ITEM (file_menu_item), file_menu);
    
    GtkWidget *open_mi = 
        gtk_image_menu_item_new_from_stock (GTK_STOCK_OPEN, NULL);
    gtk_menu_append (GTK_MENU (file_menu), open_mi);
    gtk_signal_connect (GTK_OBJECT (open_mi), "activate", 
            GTK_SIGNAL_FUNC (on_open_menu_item_activate), self);
    
    GtkWidget *save_mi = 
        gtk_image_menu_item_new_from_stock (GTK_STOCK_SAVE, NULL);
    gtk_menu_append (GTK_MENU (file_menu), save_mi);
    gtk_signal_connect (GTK_OBJECT (save_mi), "activate", 
            GTK_SIGNAL_FUNC (on_save_menu_item_activate), self);
    
    GtkWidget *quit_mi = 
        gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
    gtk_menu_append (GTK_MENU (file_menu), quit_mi);
    gtk_signal_connect (GTK_OBJECT (quit_mi), "activate", 
            GTK_SIGNAL_FUNC (gtk_main_quit), NULL);

    // view menu
    GtkWidget *view_menu_item = gtk_menu_item_new_with_mnemonic ("_View");
    gtk_menu_bar_append (GTK_MENU_BAR (menubar), view_menu_item);
    GtkWidget *view_menu = gtk_menu_new ();
    gtk_menu_item_set_submenu (GTK_MENU_ITEM (view_menu_item), view_menu);

    GtkWidget *show_manager_mi = 
        gtk_check_menu_item_new_with_mnemonic ("Show _Manager");
    gtk_menu_append (GTK_MENU (view_menu), show_manager_mi);
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_manager_mi), 
            TRUE);
    gtk_signal_connect (GTK_OBJECT (show_manager_mi), "toggled",
            GTK_SIGNAL_FUNC (on_show_manager_mi_toggled), self);
    GtkWidget *show_chain_mi = 
        gtk_check_menu_item_new_with_mnemonic ("Show _Chain");
    gtk_menu_append (GTK_MENU (view_menu), show_chain_mi);
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (show_chain_mi), TRUE);
    gtk_signal_connect (GTK_OBJECT (show_chain_mi), "toggled",
            GTK_SIGNAL_FUNC (on_show_chain_mi_toggled), self);

    // horizontal panes
    GtkWidget *hpane1 = gtk_hpaned_new ();
    gtk_box_pack_start (GTK_BOX (vbox), hpane1, TRUE, TRUE, 0);
    self->manager_frame = gtk_frame_new ("Manager");
    gtk_paned_pack1 (GTK_PANED (hpane1), self->manager_frame, FALSE, TRUE);

    
    GtkWidget *hpane2 = gtk_hpaned_new ();
    gtk_paned_pack2 (GTK_PANED(hpane1), hpane2, TRUE, TRUE);

    self->chain_frame = gtk_frame_new ("Chain");
    GtkWidget *display_frame = gtk_frame_new ("Display");
    gtk_paned_pack1 (GTK_PANED(hpane2), display_frame, TRUE, TRUE);
    gtk_paned_pack2 (GTK_PANED(hpane2), self->chain_frame, FALSE, TRUE);

    gtk_paned_set_position (GTK_PANED (hpane1), 200);
    gtk_paned_set_position (GTK_PANED (hpane2), 400);


    // manager widget
    self->manager_widget = cam_unit_manager_widget_new ();
    GtkWidget *sw1 = gtk_scrolled_window_new (NULL, NULL);
    gtk_container_add (GTK_CONTAINER (sw1), GTK_WIDGET (self->manager_widget));
    //gtk_paned_pack1 (GTK_PANED (hpane1), sw, FALSE, TRUE);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw1), 
            GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    g_signal_connect (G_OBJECT (self->manager_widget), 
            "unit-description-activated", 
            G_CALLBACK (on_unit_description_activated), self);

    // description widget
    self->desc_widget = cam_unit_description_widget_new ();
    cam_unit_description_widget_set_manager (
            CAM_UNIT_DESCRIPTION_WIDGET (self->desc_widget),
            self->manager_widget);
    GtkWidget *sw2 = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw2), 
            GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_container_add (GTK_CONTAINER (sw2), GTK_WIDGET (self->desc_widget));

    // vertical pane
    GtkWidget * vpane = gtk_vpaned_new ();
    gtk_paned_pack1 (GTK_PANED (vpane), sw1, TRUE, TRUE);
    gtk_paned_pack2 (GTK_PANED (vpane), sw2, FALSE, TRUE);
    gtk_paned_set_position (GTK_PANED (vpane), 350);
    //gtk_paned_pack1 (GTK_PANED (hpane1), vpane, FALSE, TRUE);
    gtk_container_add (GTK_CONTAINER (self->manager_frame), vpane);

    // chain gl widget
    self->chain_gl_widget = cam_unit_chain_gl_widget_new (self->chain);
    gtk_container_add (GTK_CONTAINER (display_frame), 
                GTK_WIDGET (self->chain_gl_widget));

    // chain widget
    self->chain_widget = cam_unit_chain_widget_new (self->chain);
    GtkWidget *sw_chain = gtk_scrolled_window_new (NULL, NULL);
    gtk_container_add (GTK_CONTAINER (self->chain_frame), sw_chain);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw_chain), 
            GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw_chain), 
            GTK_WIDGET (self->chain_widget));

    gtk_widget_show_all (GTK_WIDGET (self->window));

    g_timeout_add(250, decay_fps, self);
}
Beispiel #28
0
static void
gtr_dict_panel_init (GtrDictPanel * panel)
{
  GtrDictPanelPrivate *priv;
  GtkWidget *vbox;
  GtkWidget *hbox;

  panel->priv = GTR_DICT_PANEL_GET_PRIVATE (panel);
  priv = panel->priv;

  priv->status = NULL;

  if (!priv->loader)
    panel->priv->loader = gdict_source_loader_new ();

  gtk_orientable_set_orientation (GTK_ORIENTABLE (panel),
                                  GTK_ORIENTATION_VERTICAL);

  /* add our data dir inside $HOME to the loader's search paths */
  gdict_source_loader_add_search_path (priv->loader,
                                       gtr_dirs_get_user_config_dir ());

  /* settings */
  priv->settings = g_settings_new ("org.gnome.gtranslator.plugins.dictionary");

  g_signal_connect (priv->settings,
                    "changed",
                    G_CALLBACK (on_settings_changed),
                    panel);

  /* force retrieval of the configuration from gsettings */
  gtr_dict_panel_set_source_name (panel, NULL);

  /* Draw widgets */
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
  gtk_widget_show (vbox);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  /* Look up Button */
  panel->priv->button = gtk_button_new_with_mnemonic (_("Look _up:"));
  g_signal_connect (panel->priv->button, "clicked",
                    G_CALLBACK (gtr_dict_panel_entry_activate_cb), panel);
  gtk_button_set_relief (GTK_BUTTON (panel->priv->button), GTK_RELIEF_NONE);
  gtk_box_pack_start (GTK_BOX (hbox), panel->priv->button, FALSE, FALSE, 0);
  gtk_widget_show (panel->priv->button);

  /* Entry */
  panel->priv->entry = gtk_entry_new ();
  if (panel->priv->word)
    gtk_entry_set_text (GTK_ENTRY (panel->priv->entry), panel->priv->word);

  g_signal_connect (panel->priv->entry, "activate",
                    G_CALLBACK (gtr_dict_panel_entry_activate_cb), panel);
  gtk_box_pack_start (GTK_BOX (hbox), panel->priv->entry, TRUE, TRUE, 0);
  gtk_widget_show (panel->priv->entry);

  /* Defbox */
  panel->priv->defbox = gdict_defbox_new ();
  if (panel->priv->context)
    gdict_defbox_set_context (GDICT_DEFBOX (panel->priv->defbox),
                              panel->priv->context);
  g_signal_connect (panel->priv->defbox, "link-clicked",
                    G_CALLBACK (gtr_dict_panel_link_clicked), panel);

  gtk_container_add (GTK_CONTAINER (vbox), panel->priv->defbox);
  gtk_widget_show (panel->priv->defbox);

  /* Sidebar */
  panel->priv->sidebar = gdict_sidebar_new ();
  g_signal_connect (panel->priv->sidebar, "page-changed",
                    G_CALLBACK (sidebar_page_changed_cb), panel);

  /* Paned */
  panel->priv->paned = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_VERTICAL));
  gtk_box_pack_start (GTK_BOX (panel), GTK_WIDGET (panel->priv->paned), TRUE,
                      TRUE, 0);
  gtk_paned_pack1 (panel->priv->paned, vbox, FALSE, TRUE);
  gtk_paned_pack2 (panel->priv->paned, panel->priv->sidebar, TRUE, TRUE);
  gtk_widget_show (GTK_WIDGET (panel->priv->paned));

  g_settings_bind (panel->priv->settings,
                   DICTIONARY_SETTINGS_POSITION_KEY,
                   panel->priv->paned,
                   "position",
                   G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);

  /* Speller */
  panel->priv->speller = gdict_speller_new ();
  if (panel->priv->context)
    gdict_speller_set_context (GDICT_SPELLER (panel->priv->speller),
                               panel->priv->context);
  g_signal_connect (panel->priv->speller, "word-activated",
                    G_CALLBACK (speller_word_activated_cb), panel);

  gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
                          GDICT_SIDEBAR_SPELLER_PAGE,
                          _("Similar words"), panel->priv->speller);
  gtk_widget_show (panel->priv->speller);

  /* db chooser */
  panel->priv->db_chooser = gdict_database_chooser_new ();
  if (panel->priv->context)
    gdict_database_chooser_set_context (GDICT_DATABASE_CHOOSER
                                        (panel->priv->db_chooser),
                                        panel->priv->context);
  g_signal_connect (panel->priv->db_chooser, "database-activated",
                    G_CALLBACK (database_activated_cb), panel);
  gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
                          GDICT_SIDEBAR_DATABASES_PAGE,
                          _("Available dictionaries"),
                          panel->priv->db_chooser);
  gtk_widget_show (panel->priv->db_chooser);

  /* Strategy chooser */
  panel->priv->strat_chooser = gdict_strategy_chooser_new ();
  if (panel->priv->context)
    gdict_strategy_chooser_set_context (GDICT_STRATEGY_CHOOSER
                                        (panel->priv->strat_chooser),
                                        panel->priv->context);
  g_signal_connect (panel->priv->strat_chooser, "strategy-activated",
                    G_CALLBACK (strategy_activated_cb), panel);
  gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
                          GDICT_SIDEBAR_STRATEGIES_PAGE,
                          _("Available strategies"),
                          panel->priv->strat_chooser);
  gtk_widget_show (panel->priv->strat_chooser);

  /* Source chooser */
  panel->priv->source_chooser =
    gdict_source_chooser_new_with_loader (panel->priv->loader);
  g_signal_connect (panel->priv->source_chooser, "source-activated",
                    G_CALLBACK (source_activated_cb), panel);
  gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
                          GDICT_SIDEBAR_SOURCES_PAGE, _("Dictionary sources"),
                          panel->priv->source_chooser);
  gtk_widget_show (panel->priv->source_chooser);

  gtk_widget_show (panel->priv->sidebar);

}
static void
impl_constructed (GObject *object)
{
	RBPodcastAddDialog *dialog;
	GtkBuilder *builder;
	GtkWidget *widget;
	GtkWidget *paned;
	GtkTreeViewColumn *column;
	GtkCellRenderer *renderer;
	RBEntryView *episodes;
	RBShellPlayer *shell_player;
	RhythmDBQuery *query;
	RhythmDBQueryModel *query_model;
	const char *episode_strings[3];

	RB_CHAIN_GOBJECT_METHOD (rb_podcast_add_dialog_parent_class, constructed, object);
	dialog = RB_PODCAST_ADD_DIALOG (object);

	g_object_get (dialog->priv->podcast_mgr, "db", &dialog->priv->db, NULL);

	builder = rb_builder_load ("podcast-add-dialog.ui", NULL);

	dialog->priv->info_bar_message = gtk_label_new ("");
	dialog->priv->info_bar = gtk_info_bar_new ();
	g_object_set (dialog->priv->info_bar, "spacing", 0, NULL);
	gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (dialog->priv->info_bar))),
			   dialog->priv->info_bar_message);
	gtk_widget_set_no_show_all (dialog->priv->info_bar, TRUE);
	gtk_box_pack_start (GTK_BOX (dialog), dialog->priv->info_bar, FALSE, FALSE, 0);
	gtk_widget_show (dialog->priv->info_bar_message);

	dialog->priv->subscribe_button = GTK_WIDGET (gtk_builder_get_object (builder, "subscribe-button"));
	g_signal_connect_object (dialog->priv->subscribe_button, "clicked", G_CALLBACK (subscribe_clicked_cb), dialog, 0);
	gtk_widget_set_sensitive (dialog->priv->subscribe_button, FALSE);

	dialog->priv->feed_view = GTK_WIDGET (gtk_builder_get_object (builder, "feed-view"));
	g_signal_connect (dialog->priv->feed_view, "row-activated", G_CALLBACK (feed_activated_cb), dialog);
	g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->priv->feed_view)),
			  "changed",
			  G_CALLBACK (feed_selection_changed_cb),
			  dialog);


	dialog->priv->search_entry = rb_search_entry_new (FALSE);
	gtk_widget_set_size_request (GTK_WIDGET (dialog->priv->search_entry), 400, -1);
	g_object_set (dialog->priv->search_entry,"explicit-mode", TRUE, NULL);
	g_signal_connect (dialog->priv->search_entry, "search", G_CALLBACK (search_cb), dialog);
	g_signal_connect (dialog->priv->search_entry, "activate", G_CALLBACK (search_cb), dialog);
	gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (builder, "search-entry-box")),
			   GTK_WIDGET (dialog->priv->search_entry));

	g_signal_connect (gtk_builder_get_object (builder, "close-button"),
			  "clicked",
			  G_CALLBACK (close_clicked_cb),
			  dialog);

	dialog->priv->feed_model = gtk_list_store_new (7,
						       G_TYPE_STRING,	/* name */
						       G_TYPE_STRING,	/* author */
						       GDK_TYPE_PIXBUF, /* image */
						       G_TYPE_FILE,	/* image file */
						       G_TYPE_INT,	/* episode count */
						       G_TYPE_POINTER,	/* RBPodcastChannel */
						       G_TYPE_ULONG);	/* date */
	gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->priv->feed_view), GTK_TREE_MODEL (dialog->priv->feed_model));

	column = gtk_tree_view_column_new_with_attributes (_("Title"), gtk_cell_renderer_pixbuf_new (), "pixbuf", FEED_COLUMN_IMAGE, NULL);
	renderer = gtk_cell_renderer_text_new ();
	g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
	gtk_tree_view_column_pack_start (column, renderer, TRUE);
	gtk_tree_view_column_set_attributes (column, renderer, "text", FEED_COLUMN_TITLE, NULL);

	gtk_tree_view_column_set_expand (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->priv->feed_view), column);

	renderer = gtk_cell_renderer_text_new ();
	g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
	column = gtk_tree_view_column_new_with_attributes (_("Author"), renderer, "text", FEED_COLUMN_AUTHOR, NULL);
	gtk_tree_view_column_set_expand (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->priv->feed_view), column);

	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes (_("Episodes"), renderer, NULL);
	gtk_tree_view_column_set_cell_data_func (column, renderer, episode_count_column_cell_data_func, NULL, NULL);
	episode_strings[0] = "0000";
	episode_strings[1] = _("Episodes");
	episode_strings[2] = NULL;
	rb_set_tree_view_column_fixed_width (dialog->priv->feed_view, column, renderer, episode_strings, 6);
	gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->priv->feed_view), column);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "podcast-add-dialog"));
	gtk_box_pack_start (GTK_BOX (dialog), widget, TRUE, TRUE, 0);

	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (dialog->priv->feed_view), TRUE);

	/* set up episode view */
	g_object_get (dialog->priv->shell, "shell-player", &shell_player, NULL);
	episodes = rb_entry_view_new (dialog->priv->db, G_OBJECT (shell_player), TRUE, FALSE);
	g_object_unref (shell_player);

	g_signal_connect (episodes, "entry-activated", G_CALLBACK (episode_entry_activated_cb), dialog);

	/* date column */
	column = gtk_tree_view_column_new ();
	renderer = gtk_cell_renderer_text_new();

	gtk_tree_view_column_pack_start (column, renderer, TRUE);

	gtk_tree_view_column_set_clickable (column, TRUE);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
	{
		const char *sample_strings[3];
		sample_strings[0] = _("Date");
		sample_strings[1] = rb_entry_view_get_time_date_column_sample ();
		sample_strings[2] = NULL;
		rb_entry_view_set_fixed_column_width (episodes, column, renderer, sample_strings);
	}

	gtk_tree_view_column_set_cell_data_func (column, renderer,
						 (GtkTreeCellDataFunc) podcast_post_date_cell_data_func,
						 dialog, NULL);

	rb_entry_view_append_column_custom (episodes, column,
					    _("Date"), "Date",
					    (GCompareDataFunc) podcast_post_date_sort_func,
					    0, NULL);
	rb_entry_view_append_column (episodes, RB_ENTRY_VIEW_COL_TITLE, TRUE);
	rb_entry_view_append_column (episodes, RB_ENTRY_VIEW_COL_DURATION, TRUE);
	rb_entry_view_set_sorting_order (RB_ENTRY_VIEW (episodes), "Date", GTK_SORT_DESCENDING);
	g_signal_connect (episodes,
			  "notify::sort-order",
			  G_CALLBACK (episodes_sort_changed_cb),
			  dialog);

	query = rhythmdb_query_parse (dialog->priv->db,
				      RHYTHMDB_QUERY_PROP_EQUALS,
				      RHYTHMDB_PROP_TYPE,
				      RHYTHMDB_ENTRY_TYPE_PODCAST_SEARCH,
				      RHYTHMDB_QUERY_END);
	query_model = rhythmdb_query_model_new_empty (dialog->priv->db);
	rb_entry_view_set_model (episodes, query_model);

	rhythmdb_do_full_query_async_parsed (dialog->priv->db, RHYTHMDB_QUERY_RESULTS (query_model), query);
	rhythmdb_query_free (query);

	g_object_unref (query_model);

	paned = GTK_WIDGET (gtk_builder_get_object (builder, "paned"));
	g_signal_connect (paned, "size-allocate", G_CALLBACK (paned_size_allocate_cb), dialog);
	gtk_paned_pack2 (GTK_PANED (paned),
			 GTK_WIDGET (episodes),
			 TRUE,
			 FALSE);

	gtk_widget_show_all (GTK_WIDGET (dialog));
	g_object_unref (builder);
}
Beispiel #30
0
/**
 * @fn GtkWidget* create_mainwin (void)
 * Crea la ventana principal
 */
GtkWidget* create_mainwin (void)
{
	GtkWidget *app1;
	GtkWidget *dock1;
	GtkWidget *eventbox1;
	GtkWidget *viewport1;
	GtkWidget *vbox_main;
	GtkWidget *vbox_paned;
	GtkWidget *scrolledwindow;
	GtkWidget *paned;
	GtkWidget *text;
	GtkWidget *inputline;
	GtkWidget *sw;
	GtkWidget *ahbox;

	app1 = gnome_app_new ( PACKAGE, "Tenes Empanadas Graciela");
	gtk_object_set_data (GTK_OBJECT (app1), "app1", app1);
	gtk_window_set_default_size (GTK_WINDOW (app1), 664, 640);
	gtk_window_set_policy (GTK_WINDOW (app1), TRUE, TRUE, FALSE);

	dock1 = GNOME_APP (app1)->dock;
	gtk_widget_ref (dock1);
	gtk_object_set_data_full (GTK_OBJECT (app1), "dock1", dock1,
		(GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show (dock1);

	gnome_app_create_menus (GNOME_APP (app1), menubar_uiinfo);
	gnome_app_create_toolbar(GNOME_APP(app1), toolbar_main);

	/* TODO: ask in GNOME if this is wanted */
	/* gtk_menu_item_right_justify( GTK_MENU_ITEM(menubar_uiinfo[4].widget)); */

	gtk_widget_realize (app1);

	gtk_signal_connect ( GTK_OBJECT(app1), "destroy",
		GTK_SIGNAL_FUNC( on_exit_activate ), NULL );

	gtk_signal_connect ( GTK_OBJECT(app1), "delete_event",
		GTK_SIGNAL_FUNC( on_exit_activate ), NULL );


	SensiData.connect_button = toolbar_main[0].widget;
	SensiData.start_button = toolbar_main[1].widget;
	/* 2 is a separator */
	SensiData.enviarfichas_button = toolbar_main[3].widget;
	SensiData.reagrupe_button = toolbar_main[4].widget;
	SensiData.getcard_button = toolbar_main[5].widget;
	SensiData.endturn_button = toolbar_main[6].widget;
	/* 7 is a separator */
	SensiData.status_button = toolbar_main[8].widget;

	eventbox1 = gtk_event_box_new ();
	gtk_widget_ref (eventbox1);
	gtk_object_set_data_full (GTK_OBJECT (app1), "eventbox1", eventbox1,
		(GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show (eventbox1);
	gnome_app_set_contents (GNOME_APP (app1), eventbox1);

	viewport1 = gtk_viewport_new (NULL, NULL);
	gtk_widget_show (viewport1);
	gtk_container_add (GTK_CONTAINER (eventbox1), viewport1);

	vbox_main = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox_main);
	gtk_container_add (GTK_CONTAINER (viewport1), vbox_main);

	/* status map */
	if( mainstatus_create(&window_mainstatus) != TEG_STATUS_SUCCESS )
		goto error;
	gtk_box_pack_start( GTK_BOX(vbox_main), window_mainstatus, FALSE,FALSE,0);

	/* paned */
	paned = gtk_vpaned_new();
	gtk_box_pack_start( GTK_BOX( vbox_main ), paned, TRUE, TRUE, 0 );
	vbox_paned = gtk_vbox_new (FALSE, 0);
	gtk_paned_add1(GTK_PANED(paned), vbox_paned);
	gtk_widget_show (vbox_paned);

	/* map */
	scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scrolledwindow),
			GTK_POLICY_AUTOMATIC,
			GTK_POLICY_AUTOMATIC);
	gtk_widget_set_usize(scrolledwindow, 640, 394);

	if( canvas_create_map() != TEG_STATUS_SUCCESS )
		goto error;

	gtk_container_add(GTK_CONTAINER(scrolledwindow), canvas_map);
	gtk_container_add(GTK_CONTAINER(vbox_paned),scrolledwindow);
	gtk_widget_show (canvas_map);
	gtk_widget_show (scrolledwindow);


	/* text */
	ahbox = gtk_hbox_new(FALSE, 2);
	gtk_paned_pack2(GTK_PANED(paned), ahbox, TRUE, TRUE);

	sw = gtk_scrolled_window_new(NULL, NULL);

	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
					 GTK_POLICY_ALWAYS);
	gtk_box_pack_start(GTK_BOX(ahbox), sw, TRUE, TRUE, 0);

	gtk_widget_set_size_request(sw, 620, 60);

	text = gtk_text_view_new();
	gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
	gtk_container_add(GTK_CONTAINER(sw), text);

	gtk_widget_set_name(text, "chatline");

	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
	gtk_widget_realize(text);
	gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5);

	main_message_area = GTK_TEXT_VIEW(text);

/*	set_output_window_text(_("Tenes Empanadas Graciela")); */

	gtk_widget_show(text);
	gtk_widget_show(sw);
	gtk_widget_show(ahbox);
	gtk_widget_show(paned);

	/* the chat line */
	inputline = gtk_entry_new();
	gtk_box_pack_start( GTK_BOX( vbox_main ), inputline, FALSE, FALSE, 0 );
	gtk_widget_show(inputline);
	g_signal_connect(inputline, "activate", G_CALLBACK(inputline_return), NULL);


	chatline_init();


	/* status bar */
	statusbar = gnome_appbar_new (FALSE, TRUE, GNOME_PREFERENCES_NEVER);
	gtk_widget_ref (statusbar);
	gtk_object_set_data_full (GTK_OBJECT (app1), "statusbar", statusbar,
		(GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show (statusbar);
	gnome_app_set_statusbar (GNOME_APP (app1), statusbar);

	gtk_box_pack_start(GTK_BOX(statusbar),
		ministatus_build(), FALSE, TRUE, 0);


	gnome_appbar_set_status(GNOME_APPBAR(statusbar),
				_("Welcome to TEG!"));

	gnome_app_install_menu_hints( GNOME_APP(app1), menubar_uiinfo );

	/* icono */
	{
		GdkBitmap *mask;
		GdkPixmap *icono;
		#include "../teg_pix/teg_icono.xpm"
		gtk_widget_realize (app1);
		icono = gdk_pixmap_create_from_xpm_d( app1->window, &mask, &app1->style->bg[GTK_STATE_NORMAL],teg_icono_xpm );
		gdk_window_set_icon (app1->window, NULL, icono , mask );
	}

	gtk_widget_show(app1);
	return app1;

error:
	g_error(_("Unable to create map!"));
	return NULL;
}