/[paths]/src/paths.c
ViewVC logotype

Diff of /src/paths.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 41 by ben, Sun Aug 19 03:20:49 2012 UTC revision 42 by ben, Sun Aug 19 03:31:14 2012 UTC
# Line 15  activate_toggle (GSimpleAction *action, Line 15  activate_toggle (GSimpleAction *action,
15          g_action_change_state (G_ACTION (action), g_variant_new_boolean (!g_variant_get_boolean (state)));          g_action_change_state (G_ACTION (action), g_variant_new_boolean (!g_variant_get_boolean (state)));
16          g_variant_unref (state);          g_variant_unref (state);
17  }  }
   
         static void  
 activate_radio (GSimpleAction *action,  
                 GVariant      *parameter,  
                 gpointer       user_data)  
 {  
         g_action_change_state (G_ACTION (action), parameter);  
 }  
   
18          static void          static void
19  change_fullscreen_state (GSimpleAction *action,  change_fullscreen_state (GSimpleAction *action,
20                  GVariant      *state,                  GVariant      *state,
# Line 37  change_fullscreen_state (GSimpleAction * Line 28  change_fullscreen_state (GSimpleAction *
28          g_simple_action_set_state (action, state);          g_simple_action_set_state (action, state);
29  }  }
30    
         static void  
 change_justify_state (GSimpleAction *action,  
                 GVariant      *state,  
                 gpointer       user_data)  
 {  
         GtkTextView *text = g_object_get_data (user_data, "bloatpad-text");  
         const gchar *str;  
   
         str = g_variant_get_string (state, NULL);  
   
         if (g_str_equal (str, "left"))  
                 gtk_text_view_set_justification (text, GTK_JUSTIFY_LEFT);  
         else if (g_str_equal (str, "center"))  
                 gtk_text_view_set_justification (text, GTK_JUSTIFY_CENTER);  
         else if (g_str_equal (str, "right"))  
                 gtk_text_view_set_justification (text, GTK_JUSTIFY_RIGHT);  
         else  
                 /* ignore this attempted change */  
                 return;  
   
         g_simple_action_set_state (action, state);  
 }  
   
31          static GtkClipboard *          static GtkClipboard *
32  get_clipboard (GtkWidget *widget)  get_clipboard (GtkWidget *widget)
33  {  {
# Line 72  window_copy (GSimpleAction *action, Line 40  window_copy (GSimpleAction *action,
40                  gpointer       user_data)                  gpointer       user_data)
41  {  {
42          GtkWindow *window = GTK_WINDOW (user_data);          GtkWindow *window = GTK_WINDOW (user_data);
         GtkTextView *text = g_object_get_data ((GObject*)window, "bloatpad-text");  
   
         gtk_text_buffer_copy_clipboard (gtk_text_view_get_buffer (text),  
                         get_clipboard ((GtkWidget*) text));  
43  }  }
44    
45          static void          static void
# Line 84  window_paste (GSimpleAction *action, Line 48  window_paste (GSimpleAction *action,
48                  gpointer       user_data)                  gpointer       user_data)
49  {  {
50          GtkWindow *window = GTK_WINDOW (user_data);          GtkWindow *window = GTK_WINDOW (user_data);
         GtkTextView *text = g_object_get_data ((GObject*)window, "bloatpad-text");  
   
         gtk_text_buffer_paste_clipboard (gtk_text_view_get_buffer (text),  
                         get_clipboard ((GtkWidget*) text),  
                         NULL,  
                         TRUE);  
   
51  }  }
52    
53  static GActionEntry win_entries[] = {  static GActionEntry win_entries[] = {
54          { "copy", window_copy, NULL, NULL, NULL },          { "copy", window_copy, NULL, NULL, NULL },
55          { "paste", window_paste, NULL, NULL, NULL },          { "paste", window_paste, NULL, NULL, NULL },
56          { "fullscreen", activate_toggle, NULL, "false", change_fullscreen_state },          { "fullscreen", activate_toggle, NULL, "false", change_fullscreen_state }
         { "justify", activate_radio, "s", "'left'", change_justify_state }  
57  };  };
58    
59          static void          static void
60  new_window (GApplication *app,  new_window (GApplication *app,
61                  GFile        *file)                  GFile        *file)
62  {  {
63          GtkWidget *window, *grid, *scrolled, *view;          GtkWidget *window, *grid, *scrolled;
64          GtkWidget *toolbar;          GtkWidget *toolbar;
65          GtkToolItem *button;          GtkToolItem *button;
66          GtkWidget *sw, *box, *label;          GtkWidget *sw, *box, *label;
# Line 119  new_window (GApplication *app, Line 75  new_window (GApplication *app,
75    
76          toolbar = gtk_toolbar_new ();          toolbar = gtk_toolbar_new ();
77    
         button = gtk_toggle_tool_button_new_from_stock (GTK_STOCK_JUSTIFY_RIGHT);  
         gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (button), "win.justify::right");  
         gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (button));  
   
78          button = gtk_separator_tool_item_new ();          button = gtk_separator_tool_item_new ();
79          gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (button), FALSE);          gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (button), FALSE);
80          gtk_tool_item_set_expand (GTK_TOOL_ITEM (button), TRUE);          gtk_tool_item_set_expand (GTK_TOOL_ITEM (button), TRUE);
# Line 143  new_window (GApplication *app, Line 95  new_window (GApplication *app,
95          scrolled = gtk_scrolled_window_new (NULL, NULL);          scrolled = gtk_scrolled_window_new (NULL, NULL);
96          gtk_widget_set_hexpand (scrolled, TRUE);          gtk_widget_set_hexpand (scrolled, TRUE);
97          gtk_widget_set_vexpand (scrolled, TRUE);          gtk_widget_set_vexpand (scrolled, TRUE);
         view = gtk_text_view_new ();  
   
         g_object_set_data ((GObject*)window, "bloatpad-text", view);  
   
         gtk_container_add (GTK_CONTAINER (scrolled), view);  
98    
99          gtk_grid_attach (GTK_GRID (grid), scrolled, 0, 1, 1, 1);          gtk_grid_attach (GTK_GRID (grid), scrolled, 0, 1, 1, 1);
100    
# Line 160  new_window (GApplication *app, Line 107  new_window (GApplication *app,
107                  {                  {
108                          GtkTextBuffer *buffer;                          GtkTextBuffer *buffer;
109    
                         buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));  
                         gtk_text_buffer_set_text (buffer, contents, length);  
110                          g_free (contents);                          g_free (contents);
111                  }                  }
112          }          }

Legend:
Removed from v.41  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26